def __init__(self, addr=('0.0.0.0', 0)): # listeners are all couroutines waiting for a connections self.listeners = deque() self.uv = uv_server() self.sched = get_scheduler() self.task = getcurrent() self.listening = False self.handler = self.HANDLER_CLASS(self.uv.loop) self.handler.bind(addr)
def __init__(self, addr=('0.0.0.0', 0), proto="tcp"): try: self.handler_class = UV_HANDLERS[proto] except KeyError: raise ValueError("type should be tcp, udp or unix") # listeners are all couroutines waiting for a connections self.listeners = deque() self.uv = uv_server() self.sched = get_scheduler() self.task = getcurrent() self.listening = False self.handler = self.handler_class(self.uv.loop) self.handler.bind(addr)
def idle(): """ By using this function the current tasklet will be scheduled asap""" sched = core.get_scheduler() curr = core.getcurrent() def ready(now, h): curr.blocked = False sched.append(curr) core.schedule() t = timer.Timer(ready, 0.0001) t.start() curr.blocked = True core.schedule_remove()
def __init__(self): self.task = getcurrent() self.uv = uv_server() self.sched = get_scheduler() self.c = channel()