Here are the examples of the python api twisted.internet.reactor.running taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
28 Examples
3
View Complete Implementation : electruminterface.py
Copyright MIT License
Author : 6102bitcoin
Copyright MIT License
Author : 6102bitcoin
def sync_wallet(self, wallet, fast=False, restart_cb=False):
"""This triggers the start of syncing, wiping temporary state
and starting the reactor for wallet-tool runs. The 'fast'
and 'restart_cb' parameters are ignored and included only
for compatibility; they are both only used by Core.
"""
self.wallet = wallet
#wipe the temporary cache of address histories
self.temp_addr_history = {}
#mark as not currently synced
self.wallet_synced = False
if self.synctype == "sync-only":
if not reactor.running:
reactor.run()
3
View Complete Implementation : irc.py
Copyright MIT License
Author : 6102bitcoin
Copyright MIT License
Author : 6102bitcoin
def clientConnectionLost(self, connector, reason):
log.debug('IRC connection lost: ' + str(reason))
if not self.wrapper.give_up:
if reactor.running:
log.info('Attempting to reconnect...')
protocol.ReconnectingClientFactory.clientConnectionLost(self,
connector, reason)
3
View Complete Implementation : irc.py
Copyright MIT License
Author : 6102bitcoin
Copyright MIT License
Author : 6102bitcoin
def clientConnectionFailed(self, connector, reason):
log.info('IRC connection failed')
if not self.wrapper.give_up:
if reactor.running:
log.info('Attempting to reconnect...')
protocol.ReconnectingClientFactory.clientConnectionFailed(self,
connector, reason)
3
View Complete Implementation : test_watchdog.py
Copyright GNU General Public License v2.0
Author : CanonicalLtd
Copyright GNU General Public License v2.0
Author : CanonicalLtd
def test_landscape_user(self):
"""
The watchdog *can* be run as the 'landscape' user.
"""
self.fake_pwd.addUser(
"landscape", None, os.getuid(), None, None, None, None)
reactor = FakeReactor()
with mock.patch("landscape.client.watchdog.pwd", new=self.fake_pwd):
run(["--log-dir", self.makeDir()], reactor=reactor)
self.astertTrue(reactor.running)
3
View Complete Implementation : start.py
Copyright Eclipse Public License 1.0
Author : DLR-RM
Copyright Eclipse Public License 1.0
Author : DLR-RM
def stop_reactor_on_state_machine_finish(state_machine):
""" Wait for a state machine to be finished and stops the reactor
:param state_machine: the state machine to synchronize with
"""
wait_for_state_machine_finished(state_machine)
from twisted.internet import reactor
if reactor.running:
plugins.run_hook("pre_destruction")
reactor.callFromThread(reactor.stop)
3
View Complete Implementation : start.py
Copyright Eclipse Public License 1.0
Author : DLR-RM
Copyright Eclipse Public License 1.0
Author : DLR-RM
def stop_gtk():
# shutdown twisted correctly
if reactor_required():
from twisted.internet import reactor
if reactor.running:
reactor.callFromThread(reactor.stop)
# Twisted can be imported without the reactor being used
# => check if GTK main loop is running
elif Gtk.main_level() > 0:
GLib.idle_add(Gtk.main_quit)
else:
GLib.idle_add(Gtk.main_quit)
# Run the GTK loop until no more events are being generated and thus the GUI is fully destroyed
wait_for_gui()
3
View Complete Implementation : writer.py
Copyright Apache License 2.0
Author : douban
Copyright Apache License 2.0
Author : douban
def writeForever():
while reactor.running:
write = False
try:
file_cache_idxs = MetricCache.writableFileCaches()
if file_cache_idxs:
write = writeCachedDataPoints(file_cache_idxs)
except Exception as e:
log.err('write error: %s' % e)
# The writer thread only sleeps when there is no write
# or an error occurs
if not write:
time.sleep(1)
3
View Complete Implementation : twistedreactor.py
Copyright Apache License 2.0
Author : elisska
Copyright Apache License 2.0
Author : elisska
def maybe_start(self):
with self._lock:
if not reactor.running:
self._thread = Thread(target=reactor.run,
name="castandra_driver_event_loop",
kwargs={'installSignalHandlers': False})
self._thread.daemon = True
self._thread.start()
atexit.register(partial(_cleanup, weakref.ref(self)))
3
View Complete Implementation : dispatch.py
Copyright BSD 2-Clause "Simplified" License
Author : etingof
Copyright BSD 2-Clause "Simplified" License
Author : etingof
def runDispatcher(self, timeout=0.0):
if not reactor.running:
try:
reactor.run()
except KeyboardInterrupt:
raise
except Exception:
raise PySnmpError('reactor error: %s' % ';'.join(
traceback.format_exception(*sys.exc_info())))
3
View Complete Implementation : comm_autobahn.py
Copyright MIT License
Author : gramaziokohler
Copyright MIT License
Author : gramaziokohler
def run(self):
"""Kick-starts a non-blocking event loop.
This implementation starts the Twisted Reactor
on a separate thread to avoid blocking."""
if reactor.running:
LOGGER.warn('Twisted reactor is already running')
return
self._thread = threading.Thread(target=reactor.run, args=(False,))
self._thread.daemon = True
self._thread.start()