此旧代码调用不再存在的 gevent.spawn_link_exception :
def start(self, checkpoint=None):
for gl in self._greenlets:
gl.kill()
self.load_config()
self._greenlets = [
gevent.spawn_link_exception(self.periodic_checkpoint, 5) ]
for master_uri in self._config:
self._greenlets.append(
gevent.spawn_link_exception(
self.replicate, master_uri, checkpoint))
请帮我更新此代码,以便与最新版本的gevent配合使用。感谢。
答案 0 :(得分:1)
您可以通过Greenlet.link_exception
方法处理相同的事情。以下是您修改过的示例:
def start(self, checkpoint=None):
for gl in self._greenlets:
gl.kill()
self.load_config()
def exception_callback(greenlet):
print "Exception happened in ", greenlet
self._greenlets = [gevent.spawn(self.periodic_checkpoint, 5)]
self._greenlets[-1].link_exception(exception_callback)
for master_uri in self._config:
self._greenlets.append(gevent.spawn(self.replicate, master_uri, checkpoint))
self._greenlets[-1].link_exception(exception_callback)