Here are the examples of the python api twisted.internet.posixbase.PosixReactorBase.__init__ taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
23 Examples
3
Example 1
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)
3
Example 2
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)
3
Example 3
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)
3
Example 4
Project: spinoff Source File: __init__.py
def __init__(self, *args):
self.greenlet = None
self.greenletpool = Group()
self._reads = {}
self._writes = {}
self._callqueue = []
self._wake = 0
self._wait = 0
self.resolver = GeventResolver(self)
self.addToGreenletPool = self.greenletpool.add
posixbase.PosixReactorBase.__init__(self, *args)
self._initThreads()
self._initThreadPool()
self._initGreenletPool()
3
Example 5
def __init__(self, app=None):
self.running = 0
posixbase.PosixReactorBase.__init__(self)
if app is None:
app = QApplication([])
self.qApp = app
self.addSystemEventTrigger('after', 'shutdown', self.cleanup)
3
Example 6
def __init__(self, runLoop=None):
self.readers = {}
self.writers = {}
self.running = 0
self.crashing = False
self._doRunUntilCurrent = True
self.timer = None
self.runLoop = None
self.nsRunLoop = None
self.didStartRunLoop = False
if runLoop is not None:
self.getRunLoop(runLoop)
posixbase.PosixReactorBase.__init__(self)
3
Example 7
def __init__(self):
"""
Initialize epoll object, file descriptor tracking dictionaries, and the
base class.
"""
# Create the poller we're going to use. The 1024 here is just a hint
# to the kernel, it is not a hard maximum.
self._poller = _epoll.epoll(1024)
self._reads = {}
self._writes = {}
self._selectables = {}
posixbase.PosixReactorBase.__init__(self)
3
Example 8
def __init__(self):
"""
Initialize the file descriptor tracking dictionaries and the base
class.
"""
self._simtag = None
self._reads = {}
self._writes = {}
posixbase.PosixReactorBase.__init__(self)
3
Example 9
def __init__(self):
"""
Initialize kqueue object, file descriptor tracking dictionaries, and the
base class.
"""
self._kq = kqueue()
self._reads = {}
self._writes = {}
self._selectables = {}
posixbase.PosixReactorBase.__init__(self)
3
Example 10
def __init__(self):
"""
Initialize polling object, file descriptor tracking dictionaries, and
the base class.
"""
self._poller = poll()
self._selectables = {}
self._reads = {}
self._writes = {}
posixbase.PosixReactorBase.__init__(self)
3
Example 11
def __init__(self):
"""
Initialize file descriptor tracking dictionaries and the base class.
"""
self._reads = {}
self._writes = {}
posixbase.PosixReactorBase.__init__(self)
3
Example 12
Project: mythbox Source File: _threadedselect.py
def __init__(self):
threadable.init(1)
self.reads = {}
self.writes = {}
self.toThreadQueue = Queue()
self.toMainThread = Queue()
self.workerThread = None
self.mainWaker = None
posixbase.PosixReactorBase.__init__(self)
self.addSystemEventTrigger('after', 'shutdown', self._mainLoopShutdown)
3
Example 13
Project: btcx Source File: qt4reactor.py
def __init__(self):
self._reads = {}
self._writes = {}
self._notifiers = {}
self._timer = QTimer()
self._timer.setSingleShot(True)
QObject.connect(self._timer, SIGNAL("timeout()"), self.iterate)
if QCoreApplication.instance() is None:
# Application Object has not been started yet
self.qApp=QCoreApplication([])
self._ownApp=True
else:
self.qApp = QCoreApplication.instance()
self._ownApp=False
self._blockApp = None
posixbase.PosixReactorBase.__init__(self)
3
Example 14
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)
3
Example 15
def __init__(self):
"""
Initialize epoll object, file descriptor tracking dictionaries, and the
base class.
"""
# Create the poller we're going to use. The 1024 here is just a hint to
# the kernel, it is not a hard maximum. After Linux 2.6.8, the size
# argument is completely ignored.
self._poller = _epoll.epoll(1024)
self._reads = {}
self._writes = {}
self._selectables = {}
self._continuousPolling = _ContinuousPolling(self)
posixbase.PosixReactorBase.__init__(self)
3
Example 16
def __init__(self):
"""
Initialize kqueue object, file descriptor tracking dictionaries, and the
base class.
See:
- http://docs.python.org/library/select.html
- www.freebsd.org/cgi/man.cgi?query=kqueue
- people.freebsd.org/~jlemon/papers/kqueue.pdf
"""
self._kq = kqueue()
self._reads = {}
self._writes = {}
self._selectables = {}
posixbase.PosixReactorBase.__init__(self)
3
Example 17
def __init__(self):
self._reads = {}
self._writes = {}
self._events = {}
self._closedAndReading = {}
self._closedAndNotReading = WeakKeyDictionary()
posixbase.PosixReactorBase.__init__(self)
3
Example 18
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)
0
Example 19
def __init__(self, useGtk=True):
self._simtag = None
self._reads = set()
self._writes = set()
self._sources = {}
posixbase.PosixReactorBase.__init__(self)
# pre 2.3.91 the glib iteration and mainloop functions didn't release
# global interpreter lock, thus breaking thread and signal support.
if getattr(gobject, "pygtk_version", ()) >= (2, 3, 91) and not useGtk:
self.context = gobject.main_context_default()
self.__pending = self.context.pending
self.__iteration = self.context.iteration
self.loop = gobject.MainLoop()
self.__crash = self.loop.quit
self.__run = self.loop.run
else:
import gtk
self.__pending = gtk.events_pending
self.__iteration = gtk.main_iteration
self.__crash = _our_mainquit
self.__run = gtk.main
0
Example 20
def __init__(self):
self._readers = {}
self._writers = {}
PosixReactorBase.__init__(self)
0
Example 21
def __init__(self):
PosixReactorBase.__init__(self)
self.iterationTimeout = Deferred()
self.now = 100
0
Example 22
def __init__(self):
self._reads = {}
self._writes = {}
self._events = {}
posixbase.PosixReactorBase.__init__(self)
0
Example 23
def __init__(self, glib_module, gtk_module, useGtk=False):
self._simtag = None
self._reads = set()
self._writes = set()
self._sources = {}
self._glib = glib_module
self._gtk = gtk_module
posixbase.PosixReactorBase.__init__(self)
self._source_remove = self._glib.source_remove
self._timeout_add = self._glib.timeout_add
def _mainquit():
if self._gtk.main_level():
self._gtk.main_quit()
if useGtk:
self._pending = self._gtk.events_pending
self._iteration = self._gtk.main_iteration_do
self._crash = _mainquit
self._run = self._gtk.main
else:
self.context = self._glib.main_context_default()
self._pending = self.context.pending
self._iteration = self.context.iteration
self.loop = self._glib.MainLoop()
self._crash = lambda: self._glib.idle_add(self.loop.quit)
self._run = self.loop.run