()
| 46 | |
| 47 | |
| 48 | def 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): |
no test coverage detected