def __init__(self): self.loop = pyuv.Loop() self._async = pyuv.Async(self.loop, self._wakeloop) self._async.unref() self.fds = {} self._lock = threading.RLock() self.running = False # start the server task self._runtask = tasklet(self.run, "uv_server")()
def switch(self): if not self.running: self._runtask = tasklet(self.run)() getcurrent().remove() self._runtask.switch()