code: def _spawn(self, func: Callable, *args, **kwargs) -> gevent.Greenlet:
          
  
          def on_success(greenlet):
              if greenlet in self.greenlets:
                  self.greenlets.remove(greenlet)
  
          greenlet = gevent.spawn(func, *args, **kwargs)
          greenlet.link_exception(self.on_error)
          greenlet.link_value(on_success)
          self.greenlets.append(greenlet)
          return greenlet
docs: Spawn a sub-task and ensures an error on it crashes self/main greenlet