예제 #1
0
파일: hub.py 프로젝트: inercia/evy
 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
예제 #2
0
파일: hub.py 프로젝트: PlumpMath/evy
 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
예제 #3
0
파일: hub.py 프로젝트: inercia/evy
    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")
예제 #4
0
파일: hub.py 프로젝트: PlumpMath/evy
    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")
예제 #5
0
파일: threads.py 프로젝트: inercia/evy
 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
예제 #6
0
 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