def test_detect_environment(self): try: compat._environment = None X = compat.detect_environment() assert compat._environment == X Y = compat.detect_environment() assert Y == X finally: compat._environment = None
def __init__(self, backend, app, accept, pending_results, pending_messages): self.backend = backend self.app = app self.accept = accept self._pending_results = pending_results self._pending_messages = pending_messages self.on_message = None self.buckets = WeakKeyDictionary() self.drainer = drainers[detect_environment()](self)
def get_future_executor(): """Future executor factory method.""" global _executor if _executor: return _executor executor = defaultFutureExecutor environment = detect_environment() if environment == 'eventlet': from eventlet.patcher import is_monkey_patched if is_monkey_patched('os') or is_monkey_patched('select'): raise RuntimeError( "it currently doesn't support coroutine execution under " "eventlet's heavy monkey patch.") executor = eventletFutureExecutor elif environment == 'gevent': executor = geventFutureExecutor _executor = executor return _executor
def should_use_eventloop(self): return (detect_environment() == 'default' and self._conninfo.transport.implements.asynchronous and not self.app.IS_WINDOWS)