Exemplo n.º 1
0
 def __init__(self, app=None):
     self._reads = {}
     self._writes = {}
     if app is None:
         app = QApplication([])
     self.qApp = app
     PosixReactorBase.__init__(self)
     self.addSystemEventTrigger('after', 'shutdown', self.cleanup)
Exemplo n.º 2
0
 def __init__(self, io_loop=None):
     if not io_loop:
         io_loop = tornado.ioloop.IOLoop.instance()
     self._io_loop = io_loop
     self._readers = {}
     self._writers = {}
     self._fds = {} # a map of fd to a (reader, writer) tuple
     self._delayedCalls = {}
     self._running = False
     self._closed = False
     PosixReactorBase.__init__(self)
Exemplo n.º 3
0
    def __init__(self, runLoop=None, runner=None):
        self._fdmap = {}
        self._idmap = {}
        if runner is None:
            runner = CFRunLoopRun
        self._runner = runner

        if runLoop is None:
            runLoop = CFRunLoopGetMain()
        self._cfrunloop = runLoop
        PosixReactorBase.__init__(self)
Exemplo n.º 4
0
 def crash(self):
     """
     Implement L{IReactorCore.crash}
     """
     wasStarted = self._started
     PosixReactorBase.crash(self)
     if self._inCFLoop:
         self._stopNow()
     else:
         if wasStarted:
             self.callLater(0, self._stopNow)
Exemplo n.º 5
0
 def crash(self):
     if not self._running:
         return
     self._running = False
     PosixReactorBase.crash(self)
     self.runUntilCurrent()
     try:
         self._io_loop.stop()
         self._io_loop.close()
     except:
         # Ignore any exceptions thrown by IOLoop
         pass
     self._closed = True
Exemplo n.º 6
0
 def __init__(self):
     """Initialize reactor and local fd storage."""
     # These inits really ought to be before
     # L{PosixReactorBase.__init__} call, because it adds the
     # waker in the process
     self._reads = {}
     self._writes = {}
     self._selectables = {}
     self._signal_handlers = []
     from syncless import coio
     self._wakeup_info = coio.wakeup_info()
     self._pending_events = self._wakeup_info.pending_events
     PosixReactorBase.__init__(self)
Exemplo n.º 7
0
 def stop(self):
     """
     Implement L{IReactorCore.stop}.
     """
     self._running = False
     PosixReactorBase.stop(self)
     self.runUntilCurrent()
     try:
         self._io_loop.stop()
         self._io_loop.close()
     except:
         # Ignore any exceptions thrown by IOLoop
         pass
     self._closed = True
Exemplo n.º 8
0
 def __init__(self):
     self._reads = {}
     self._writes = {}
     self._timer = QTimer()
     self._timer.setSingleShot(True)
     if QCoreApplication.startingUp():
         self.qApp = QCoreApplication([])
         self._ownApp = True
     else:
         self.qApp = QCoreApplication.instance()
         self._ownApp = False
     self._blockApp = None
     self._readWriteQ = []
     PosixReactorBase.__init__(self)
Exemplo n.º 9
0
	def __init__(self):
		self._reads = {}
		self._writes = {}
		self.savedTimeout = None
		self._timer = eTimer()
		self._timer.callback.append(self.simulate)
		self._insimulate = False
		self._wakeupPending = False
		# to limit the systemcalls per loop
		# twistes gets a cached monotonic time for internal timers
		# only updated once per loop (monotonic_time call in def simulate)
		PosixReactorBase.seconds = self.now
		PosixReactorBase.__init__(self)
		self.addSystemEventTrigger('after', 'shutdown', self.cleanup)
Exemplo n.º 10
0
 def __init__(self):
     self._loop = pyuv.Loop()
     self._async_handle = pyuv.Async(self._loop, self._async_cb)
     self._async_handle_lock = threading.Lock()
     self._async_callbacks = deque()
     self._readers = {}  # map of reader objects to fd
     self._writers = {}  # map of writer objects to fd
     self._fds = {}      # map of fd to a (reader, writer) tuple
     self._delayedCalls = {}
     self._poll_handles = {}
     self._signal_fds = SocketPair()
     self._signal_checker = pyuv.util.SignalChecker(self._loop, self._signal_fds.reader_fileno())
     self._signal_checker.unref()
     self._signal_checker.start()
     PosixReactorBase.__init__(self)
Exemplo n.º 11
0
    def __init__(self):
        QObject.__init__(self)

        self._readers = {}
        self._writers = {}
        self._timer = QTimer()
        self._timer.setSingleShot(True)
        self.connect(self._timer, SIGNAL("timeout()"), self._timerSlot)

        self._eventLoop = QCoreApplication.instance()
        if self._eventLoop is None:
            # create dummy application for testing
            self._eventLoop = QCoreApplication([])

        PosixReactorBase.__init__(self)  # goes last, because it calls addReader
Exemplo n.º 12
0
    def __init__(self):
        self._io_loop = tornado.ioloop.IOLoop.current()
        self._readers = {}  # map of reader objects to fd
        self._writers = {}  # map of writer objects to fd
        self._fds = {}  # a map of fd to a (reader, writer) tuple
        self._delayedCalls = {}
        PosixReactorBase.__init__(self)
        self.addSystemEventTrigger('during', 'shutdown', self.crash)

        # IOLoop.start() bypasses some of the reactor initialization.
        # Fire off the necessary events if they weren't already triggered
        # by reactor.run().
        def start_if_necessary():
            if not self._started:
                self.fireSystemEvent('startup')
        self._io_loop.add_callback(start_if_necessary)
Exemplo n.º 13
0
 def callLater(self, _seconds, _f, *args, **kw):
     """
     Implement L{IReactorTime.callLater}.
     """
     delayedCall = PosixReactorBase.callLater(
         self, _seconds, _f, *args, **kw
     )
     self._scheduleSimulate()
     return delayedCall
Exemplo n.º 14
0
    def __init__(self, io_loop=None):
        if not io_loop:
            io_loop = tornado.ioloop.IOLoop.current()
        self._io_loop = io_loop
        self._readers = {}  # map of reader objects to fd
        self._writers = {}  # map of writer objects to fd
        self._fds = {}  # a map of fd to a (reader, writer) tuple
        self._delayedCalls = {}
        PosixReactorBase.__init__(self)
        self.addSystemEventTrigger('during', 'shutdown', self.crash)

        # IOLoop.start() bypasses some of the reactor initialization.
        # Fire off the necessary events if they weren't already triggered
        # by reactor.run().
        def start_if_necessary():
            if not self._started:
                self.fireSystemEvent('startup')
        self._io_loop.add_callback(start_if_necessary)
Exemplo n.º 15
0
 def callLater(self, _seconds, _f, *args, **kw):
     """
     Implement L{IReactorTime.callLater}.
     """
     delayedCall = PosixReactorBase.callLater(
         self, _seconds, _f, *args, **kw
     )
     self._scheduleSimulate()
     return delayedCall
Exemplo n.º 16
0
    def __init__(self, io_loop=None):
        if not io_loop:
            io_loop = tornado.ioloop.IOLoop.instance()
        self._io_loop = io_loop
        self._readers = {}  # map of reader objects to fd
        self._writers = {}  # map of writer objects to fd
        self._fds = {}  # a map of fd to a (reader, writer) tuple
        self._delayedCalls = {}
        PosixReactorBase.__init__(self)

        # IOLoop.start() bypasses some of the reactor initialization.
        # Fire off the necessary events if they weren't already triggered
        # by reactor.run().
        def start_if_necessary():
            if not self._started:
                self.fireSystemEvent("startup")

        self._io_loop.add_callback(start_if_necessary)
Exemplo n.º 17
0
 def __init__(self):
     self._reads = {}
     self._writes = {}
     self._timer=QTimer()
     self._timer.setSingleShot(True)
     if QCoreApplication.startingUp():
         self.qApp=QCoreApplication([])
         self._ownApp=True
     else:
         self.qApp = QCoreApplication.instance()
         self._ownApp=False
     self._blockApp = None
     self._readWriteQ=[]
     
     """ some debugging instrumentation """
     self._doSomethingCount=0
     
     PosixReactorBase.__init__(self)
Exemplo n.º 18
0
 def _moveCallLaterSooner(self, tple):
     """
     Override L{PosixReactorBase}'s implementation of L{IDelayedCall.reset}
     so that it will immediately reschedule.  Normally
     C{_moveCallLaterSooner} depends on the fact that C{runUntilCurrent} is
     always run before the mainloop goes back to sleep, so this forces it to
     immediately recompute how long the loop needs to stay asleep.
     """
     result = PosixReactorBase._moveCallLaterSooner(self, tple)
     self._scheduleSimulate()
     return result
Exemplo n.º 19
0
 def _moveCallLaterSooner(self, tple):
     """
     Override L{PosixReactorBase}'s implementation of L{IDelayedCall.reset}
     so that it will immediately reschedule.  Normally
     C{_moveCallLaterSooner} depends on the fact that C{runUntilCurrent} is
     always run before the mainloop goes back to sleep, so this forces it to
     immediately recompute how long the loop needs to stay asleep.
     """
     result = PosixReactorBase._moveCallLaterSooner(self, tple)
     self._scheduleSimulate()
     return result
Exemplo n.º 20
0
    def __init__(self, io_loop=None):
        if not io_loop:
            io_loop = tornado.ioloop.IOLoop.instance()
        self._io_loop = io_loop
        self._readers = {}  # map of reader objects to fd
        self._writers = {}  # map of writer objects to fd
        self._fds = {}  # a map of fd to a (reader, writer) tuple
        self._delayedCalls = {}
        PosixReactorBase.__init__(self)
        # The default is a ThreadedResolver which spawns worker threads
        # from a thread pool which is probably *correct* but was quite
        # confusing and inconsistent with default Tornado behavior.
        self.installResolver(BlockingResolver())
        self.addSystemEventTrigger('during', 'shutdown', self.crash)

        # IOLoop.start() bypasses some of the reactor initialization.
        # Fire off the necessary events if they weren't already triggered
        # by reactor.run().
        def start_if_necessary():
            if not self._started:
                self.fireSystemEvent('startup')
        self._io_loop.add_callback(start_if_necessary)
Exemplo n.º 21
0
    def __init__(self, io_loop=None):
        if not io_loop:
            io_loop = tornado.ioloop.IOLoop.instance()
        self._io_loop = io_loop
        self._readers = {}  # map of reader objects to fd
        self._writers = {}  # map of writer objects to fd
        self._fds = {}  # a map of fd to a (reader, writer) tuple
        self._delayedCalls = {}
        PosixReactorBase.__init__(self)
        # The default is a ThreadedResolver which spawns worker threads
        # from a thread pool which is probably *correct* but was quite
        # confusing and inconsistent with default Tornado behavior.
        self.installResolver(BlockingResolver())
        self.addSystemEventTrigger('during', 'shutdown', self.crash)

        # IOLoop.start() bypasses some of the reactor initialization.
        # Fire off the necessary events if they weren't already triggered
        # by reactor.run().
        def start_if_necessary():
            if not self._started:
                self.fireSystemEvent('startup')

        self._io_loop.add_callback(start_if_necessary)
Exemplo n.º 22
0
 def crash(self):
     PosixReactorBase.crash(self)
     self._eventLoop.quit()
Exemplo n.º 23
0
 def crash(self):
     PosixReactorBase.crash(self)
     self._eventLoop.quit()
Exemplo n.º 24
0
 def callLater(self, *args, **kwargs):
     result = PosixReactorBase.callLater(self, *args, **kwargs)
     self._scheduleSimulation()
     return result
Exemplo n.º 25
0
 def crash(self):
     PosixReactorBase.crash(self)
     self._io_loop.stop()
Exemplo n.º 26
0
 def _moveCallLaterSooner(self, tple):
     result = PosixReactorBase._moveCallLaterSooner(self, tple)
     self._scheduleSimulate()
     return result
Exemplo n.º 27
0
 def __init__(self, eventloop):
     self._asyncioEventloop = eventloop
     self._writers = set()
     self._readers = set()
     self._delayedCalls = set()
     PosixReactorBase.__init__(self)
Exemplo n.º 28
0
 def __init__(self):
     self._readers = {}
     self._writers = {}
     PosixReactorBase.__init__(self)
Exemplo n.º 29
0
 def callLater(self, seconds, f, *args, **kwargs):
     dc = PosixReactorBase.callLater(self, seconds, f, *args, **kwargs)
     abs_time = self._asyncioEventloop.time() + self.timeout()
     if self._scheduledAt is None or abs_time < self._scheduledAt:
         self._reschedule()
     return dc
Exemplo n.º 30
0
 def stop(self):
     """
     Implement L{IReactorCore.stop}.
     """
     PosixReactorBase.stop(self)
     self._scheduleSimulate(True)
Exemplo n.º 31
0
 def stop(self):
     PosixReactorBase.stop(self)
     self.callLater(0, self.fireSystemEvent, "shutdown")
Exemplo n.º 32
0
 def callLater(self, _seconds, _f, *args, **kw):
     ret = PosixReactorBase.callLater(self, _seconds, _f, *args, **kw)
     if not self._wakeupPending:
         self.wakeUp()
         self._wakeupPending = True
     return ret
Exemplo n.º 33
0
 def crash(self):
     PosixReactorBase.crash(self)
     self._asyncioEventloop.stop()
Exemplo n.º 34
0
 def __init__(self, eventloop):
     self._asyncioEventloop = eventloop
     self._writers = set()
     self._readers = set()
     self._delayedCalls = set()
     PosixReactorBase.__init__(self)
Exemplo n.º 35
0
 def _moveCallLaterSooner(self, tple):
     result = PosixReactorBase._moveCallLaterSooner(self, tple)
     self._scheduleSimulate()
     return result
Exemplo n.º 36
0
 def __init__(self):
     PosixReactorBase.__init__(self)
     self.iterationTimeout = Deferred()
     self.now = 100
Exemplo n.º 37
0
 def stop(self):
     PosixReactorBase.stop(self)
     self._scheduleSimulation()
Exemplo n.º 38
0
 def _moveCallLaterSooner(self, tple):
     PosixReactorBase._moveCallLaterSooner(self, tple)
     self._reschedule()
Exemplo n.º 39
0
 def callLater(self, *args, **kwargs):
     result = PosixReactorBase.callLater(self, *args, **kwargs)
     self._scheduleSimulation()
     return result
Exemplo n.º 40
0
 def stop(self):
     PosixReactorBase.stop(self)
     self._io_loop.stop()
Exemplo n.º 41
0
 def crash(self):
     PosixReactorBase.crash(self)
     for handler in self._signal_handlers:
         handler.delete()
     del self._signal_handlers[:]
Exemplo n.º 42
0
 def stop(self):
     """
     Implement L{IReactorCore.stop}.
     """
     PosixReactorBase.stop(self)
     self._scheduleSimulate(True)
Exemplo n.º 43
0
 def register_with_reactor(self, reactor: PosixReactorBase):
     reactor.listenUDP(0, self)
Exemplo n.º 44
0
	def callLater(self, _seconds, _f, *args, **kw):
		ret = PosixReactorBase.callLater(self, _seconds, _f, *args, **kw)
		if not self._wakeupPending:
			self.wakeUp()
			self._wakeupPending = True
		return ret
Exemplo n.º 45
0
 def __init__(self):
     PosixReactorBase.__init__(self)
     self.iterationTimeout = Deferred()
     self.now = 100
Exemplo n.º 46
0
 def stop(self):
     PosixReactorBase.stop(self)
     fire_shutdown = functools.partial(self.fireSystemEvent, "shutdown")
     self._io_loop.add_callback(fire_shutdown)
Exemplo n.º 47
0
 def __init__(self):
     self._readers = {}
     self._writers = {}
     PosixReactorBase.__init__(self)
Exemplo n.º 48
0
 def crash(self):
     PosixReactorBase.crash(self)
     for handler in self._signal_handlers:
         handler.delete()
     del self._signal_handlers[:]
Exemplo n.º 49
0
 def stop(self):
     PosixReactorBase.stop(self)
     self._io_loop.stop()
Exemplo n.º 50
0
 def crash(self):
     PosixReactorBase.crash(self)
     self.wakeUp()
Exemplo n.º 51
0
 def stop(self):
     PosixReactorBase.stop(self)
     self._scheduleSimulation()