1

This old code makes a call to gevent.spawn_link_exception which no longer exists:

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))

Please help me to update this code so that it works with the latest version of gevent. Thanks.

mcmacerson
  • 885
  • 2
  • 14
  • 17

1 Answers1

1

You can approach the same thing via Greenlet.link_exception method. Here is your modified example:

  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)
Dmitry Nedbaylo
  • 2,254
  • 1
  • 20
  • 20