def _yield_to_others(sleep): if any( [gevent.monkey.is_module_patched(mod) for mod in ["socket", "subprocess"]]): gevent.wait(timeout=sleep) else: time.sleep(sleep)