本文整理汇总了Python中eventlet.monkey_patch方法的典型用法代码示例。如果您正苦于以下问题:Python eventlet.monkey_patch方法的具体用法?Python eventlet.monkey_patch怎么用?Python eventlet.monkey_patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eventlet
的用法示例。
在下文中一共展示了eventlet.monkey_patch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: maybe_monkeypatched_threading
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def maybe_monkeypatched_threading(request):
if request.param == "eventlet":
try:
eventlet.monkey_patch()
except AttributeError as e:
if "'thread.RLock' object has no attribute" in str(e):
# https://bitbucket.org/pypy/pypy/issues/2962/gevent-cannot-patch-rlock-under-pypy-27-7
pytest.skip("https://github.com/eventlet/eventlet/issues/546")
else:
raise
elif request.param == "gevent":
try:
gevent.monkey.patch_all()
except Exception as e:
if "_RLock__owner" in str(e):
pytest.skip("https://github.com/gevent/gevent/issues/1380")
else:
raise
else:
assert request.param is None
return request.param
示例2: run
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def run(self, handler):
from eventlet import wsgi, listen, patcher
if not patcher.is_monkey_patched(os):
msg = "Bottle requires eventlet.monkey_patch() (before import)"
raise RuntimeError(msg)
socket_args = {}
for arg in ('backlog', 'family'):
try:
socket_args[arg] = self.options.pop(arg)
except KeyError:
pass
address = (self.host, self.port)
try:
wsgi.server(listen(address, **socket_args), handler,
log_output=(not self.quiet))
except TypeError:
# Fallback, if we have old version of eventlet
wsgi.server(listen(address), handler)
示例3: start
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def start(self, use_eventlet=False, eventlet_monkey_patch=False, catch_signals=True):
# First do a blocking long poll to populate the local cache, otherwise we may get racing problems
if len(self._cache) == 0:
self._long_poll()
if use_eventlet:
import eventlet
if eventlet_monkey_patch:
eventlet.monkey_patch()
eventlet.spawn(self._listener)
else:
if catch_signals:
import signal
signal.signal(signal.SIGINT, self._signal_handler)
signal.signal(signal.SIGTERM, self._signal_handler)
signal.signal(signal.SIGABRT, self._signal_handler)
t = threading.Thread(target=self._listener)
t.start()
示例4: __call__
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def __call__(self, app, host, port, use_debugger, use_reloader):
# override the default runserver command to start a Socket.IO server
if use_debugger is None:
use_debugger = app.debug
if use_debugger is None:
use_debugger = True
if use_reloader is None:
use_reloader = app.debug
import eventlet
# monkey_patch
eventlet.monkey_patch()
socketio.run(app,
host=host,
port=port,
debug=use_debugger,
use_reloader=use_reloader,
**self.server_options)
示例5: main
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def main():
log.register_options(CONF)
gmr_opts.set_defaults(CONF)
CONF(sys.argv[1:], project='manila',
version=version.version_string())
log.setup(CONF, "manila")
utils.monkey_patch()
gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)
launcher = service.process_launcher()
if CONF.enabled_share_backends:
for backend in CONF.enabled_share_backends:
host = "%s@%s" % (CONF.host, backend)
server = service.Service.create(host=host,
service_name=backend,
binary='manila-share',
coordination=True)
launcher.launch_service(server)
else:
server = service.Service.create(binary='manila-share')
launcher.launch_service(server)
launcher.wait()
示例6: test_can_create_with_kwargs
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def test_can_create_with_kwargs(self):
"""Test for lp 1812935
Note that in order to reproduce the bug, it is necessary to add the
following to the top of oslo_cache/tests/__init__.py::
import eventlet
eventlet.monkey_patch()
This should happen before any other imports in that file.
"""
client = _memcache_pool._MemcacheClient('foo', check_keys=False)
# Make sure kwargs are properly processed by the client
self.assertFalse(client.do_check_key)
# Make sure our __new__ override still results in the right type
self.assertIsInstance(client, _memcache_pool._MemcacheClient)
示例7: _main
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def _main():
import eventlet
eventlet.monkey_patch(all=True)
# Monkey patch the original current_thread to use the up-to-date _active
# global variable. See https://bugs.launchpad.net/bugs/1863021 and
# https://github.com/eventlet/eventlet/issues/592
import __original_module_threading as orig_threading
import threading # noqa
orig_threading.current_thread.__globals__['_active'] = threading._active
from oslo_config import cfg
logging.basicConfig(level=logging.DEBUG)
conf = cfg.ConfigOpts()
conf.register_cli_opts(_options.eventlet_backdoor_opts)
conf(sys.argv[1:])
where_running_thread = _initialize_if_enabled(conf)
if not where_running_thread:
raise RuntimeError(_("Did not create backdoor at requested location"))
else:
_where_running, thread = where_running_thread
thread.wait()
示例8: test_uri_length_limit
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def test_uri_length_limit(self):
eventlet.monkey_patch(os=False, thread=False)
server = wsgi.Server(self.conf, "test_uri_length_limit", None,
host="127.0.0.1", max_url_len=16384, port=33337)
server.start()
self.assertFalse(server._server.dead)
uri = "http://127.0.0.1:%d/%s" % (server.port, 10000 * 'x')
resp = requests.get(uri, proxies={"http": ""})
eventlet.sleep(0)
self.assertNotEqual(requests.codes.REQUEST_URI_TOO_LARGE,
resp.status_code)
uri = "http://127.0.0.1:%d/%s" % (server.port, 20000 * 'x')
resp = requests.get(uri, proxies={"http": ""})
eventlet.sleep(0)
self.assertEqual(requests.codes.REQUEST_URI_TOO_LARGE,
resp.status_code)
server.stop()
server.wait()
示例9: monkey_patch
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def monkey_patch(patch_thread=None):
"""
Function which performs eventlet monkey patching and also takes into account "--use-debugger"
argument in the command line arguments.
If this argument is found, no monkey patching is performed for the thread module. This allows
user to use remote debuggers.
:param patch_thread: True to also patch the thread module. If not provided, thread module is
patched unless debugger is used.
:type patch_thread: ``bool``
"""
import eventlet
if patch_thread is None:
patch_thread = not is_use_debugger_flag_provided()
eventlet.monkey_patch(os=True, select=True, socket=True, thread=patch_thread, time=True)
示例10: run
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def run(servername, ip, port, softcron=True, logging=False, profiler=None,
options=None):
if servername == 'gevent':
from gevent import monkey
monkey.patch_all()
elif servername == 'eventlet':
import eventlet
eventlet.monkey_patch()
import gluon.main
if logging:
application = gluon.main.appfactory(wsgiapp=gluon.main.wsgibase,
logfilename='httpserver.log',
profiler_dir=profiler)
else:
application = gluon.main.wsgibase
if softcron:
from gluon.settings import global_settings
global_settings.web2py_crontype = 'soft'
getattr(Servers, servername)(application, (ip, int(port)), options=options)
示例11: patch
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def patch(self):
hubs.use_hub()
eventlet.monkey_patch(os=False)
patch_sendfile()
示例12: _cli_patch
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def _cli_patch(cli_args): # pragma: no coverage
parsed_args, _ = _cli_parse(cli_args)
opts = parsed_args
if opts.server:
if opts.server.startswith('gevent'):
import gevent.monkey
gevent.monkey.patch_all()
elif opts.server.startswith('eventlet'):
import eventlet
eventlet.monkey_patch()
示例13: setup
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def setup(cls):
eventlet.sleep() # workaround for import cycle: https://github.com/eventlet/eventlet/issues/401
eventlet.monkey_patch(thread=False)
if 'pytest' not in sys.modules:
import getpass
getpass.os = eventlet.patcher.original('os') # workaround for https://github.com/eventlet/eventlet/issues/340
sys.stdout = cls.MUXER
示例14: main
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def main():
log.register_options(CONF)
gmr_opts.set_defaults(CONF)
CONF(sys.argv[1:], project='manila',
version=version.version_string())
log.setup(CONF, "manila")
utils.monkey_patch()
gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)
server = service.Service.create(binary='manila-scheduler',
coordination=True)
service.serve(server)
service.wait()
示例15: main
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import monkey_patch [as 别名]
def main():
log.register_options(CONF)
gmr_opts.set_defaults(CONF)
CONF(sys.argv[1:], project='manila',
version=version.version_string())
log.setup(CONF, "manila")
utils.monkey_patch()
gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)
server = service.Service.create(binary='manila-data')
service.serve(server)
service.wait()