-2
我通过geopy运行Nominatim Web服务,但由于使用策略或Internet连接,它经常失败。如何处理发生停止的失败连接,并在几秒或几分钟后重新运行代码。该错误信息是:如何使用Nominatim处理错误?
GeocoderServiceError: <urlopen error [Errno 10060] A connection attempt failed because the
connected party did not properly respond after a period of time, or established connection
failed because connected host has failed to respond>
和
GeocoderServiceError: HTTP Error 420: unused
伪代码将是这样的:
try:
run web service
except:
stop several seconds or minutes and rerun webservice at the same line and loops
(if it fails again)
stop 30 minutes and rerun webservice
任何暗示或建议将是最欢迎的。
谢谢!
我认为你应该弄清楚,为什么它经常跌倒。这不应该发生。 – kecer 2014-09-01 13:06:47
尽量不要使用像'我想知道'的短语 - 而要问一个问题,比如'我怎样才能' – Cullub 2014-09-01 13:06:47
这是很肤浅的,但只是把这段代码放在while循环中,另外尝试/ except不忽略错误“它完全相反,你需要知道你想要捕捉哪个错误以及如何处理它,除非标记不是一个接一个,否则except标记将不会在相同的尝试中工作两次,但除了1或except2或....除N 。 – 2014-09-01 13:12:36