def ensure_greenlet (self): if self.greenlet.dead: # create new greenlet sharing same parent as original new = greenlet.greenlet(self.run, self.greenlet.parent) # need to assign as parent of old greenlet # for those greenlets that are currently # children of the dead hub and may subsequently # exit without further switching to hub. self.greenlet.parent = new self.greenlet = new
def ensure_greenlet(self): if self.greenlet.dead: # create new greenlet sharing same parent as original new = greenlet.greenlet(self.run, self.greenlet.parent) # need to assign as parent of old greenlet # for those greenlets that are currently # children of the dead hub and may subsequently # exit without further switching to hub. self.greenlet.parent = new self.greenlet = new
def __init__ (self, clock = time.time, ptr = None, default = True): """ :param clock: :type clock: :param default: default loop :type default: boolean :param ptr: a pointer a an (optional) libuv loop :type ptr: a "uv_loop_t*" """ self.clock = clock self.greenlet = greenlet.greenlet(self.run) self.stopping = False self.running = False self.timers = set() self.pollers = {} self.callbacks = set() self.debug_exceptions = True self.debug_blocking = False self.debug_blocking_resolution = 1 self.interrupted = False if ptr: self.uv_loop = ptr else: if _default_loop_destroyed: default = False self.uv_sighandlers = set() self.uv_loop = pyuv.Loop.default_loop() if default: #self.uv_signal_checker = pyuv.SignalChecker(self.uv_loop) for signum in self.SYSTEM_EXCEPTIONS_SIGNUMS: handler = pyuv.Signal(self.uv_loop) handler.start(self.signal_received, int(signum)) self.uv_sighandlers.add(handler) #else: # self.uv_signal_checker = None if not self.uv_loop: raise SystemError("default_loop() failed")
def __init__(self, clock=time.time, ptr=None, default=True): """ :param clock: :type clock: :param default: default loop :type default: boolean :param ptr: a pointer a an (optional) libuv loop :type ptr: a "uv_loop_t*" """ self.clock = clock self.greenlet = greenlet.greenlet(self.run) self.stopping = False self.running = False self.timers = set() self.pollers = {} self.callbacks = set() self.debug_exceptions = True self.debug_blocking = False self.debug_blocking_resolution = 1 self.interrupted = False if ptr: self.uv_loop = ptr else: if _default_loop_destroyed: default = False self.uv_sighandlers = set() self.uv_loop = pyuv.Loop.default_loop() if default: #self.uv_signal_checker = pyuv.SignalChecker(self.uv_loop) for signum in self.SYSTEM_EXCEPTIONS_SIGNUMS: handler = pyuv.Signal(self.uv_loop) handler.start(self.signal_received, int(signum)) self.uv_sighandlers.add(handler) #else: # self.uv_signal_checker = None if not self.uv_loop: raise SystemError("default_loop() failed")
def _run_callback (func, args, kwargs): hub = hubs.get_hub() g = greenlet.greenlet(func, parent = hub.greenlet) hub.run_callback(g.switch, *args, **kwargs) return g
def _run_callback(func, args, kwargs): hub = hubs.get_hub() g = greenlet.greenlet(func, parent=hub.greenlet) hub.run_callback(g.switch, *args, **kwargs) return g