MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / init_reactor

Function init_reactor

txcouchbase/tests/conftest.py:48–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46
47
48def init_reactor():
49 from twisted.internet import asyncioreactor
50
51 from acouchbase import get_event_loop
52 try:
53 asyncioreactor.install(get_event_loop())
54 except ReactorAlreadyInstalledError as ex:
55 print(f'Twisted setup: {ex}')
56 finally:
57 import twisted.internet.reactor
58
59 TwistedObjects._REACTOR = twisted.internet.reactor
60 if not hasattr(TwistedObjects._REACTOR, '_asyncioEventloop'):
61 raise RuntimeError(
62 "Reactor installed is not the asyncioreactor.")
63
64 TwistedObjects._TWISTED_THREAD = threading.Thread(target=lambda: run_reactor(TwistedObjects._REACTOR))
65 TwistedObjects._REACTOR.suggestThreadPoolSize(10)
66 TwistedObjects._TWISTED_THREAD.start()
67
68# hook to catch prior to running tests
69# def pytest_runtest_call(item):

Callers 1

pytest_configureFunction · 0.85

Calls 3

get_event_loopFunction · 0.90
run_reactorFunction · 0.85
startMethod · 0.45

Tested by

no test coverage detected