本文整理汇总了Python中eventlet.green方法的典型用法代码示例。如果您正苦于以下问题:Python eventlet.green方法的具体用法?Python eventlet.green怎么用?Python eventlet.green使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eventlet
的用法示例。
在下文中一共展示了eventlet.green方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: report
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import green [as 别名]
def report(self, autocolor=True):
total = 0
errors = []
for r in self.traversal:
total += 1
if r.is_leaf_error():
exc = r.exception[1]
indent = " "
if getattr(exc, "report_traceback", True):
tb = "\n\n" + r.get_traceback().strip()
errors.append("%s%s: unexpected error%s" % (indent, r.executor.name,
tb.replace("\n", "\n " + indent)))
else:
errors.append("%s%s: %s" % (indent, r.executor.context, exc))
if autocolor:
if errors:
color = self.terminal.bold_red
else:
color = self.terminal.green
else:
color = lambda x: x
result = "\n".join(["%s tasks run, %s errors" % (total, len(errors))] + errors)
return "\n".join([color(line) for line in result.splitlines()])
示例2: _single_run
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import green [as 别名]
def _single_run(self, application, sock):
"""Start a WSGI server in a new green thread."""
LOG.info("Starting single process server")
eventlet.wsgi.server(sock, application, custom_pool=self.pool,
log=self._wsgi_logger,
debug=False,
keepalive=CONF.api.http_keepalive)
示例3: test_hang
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import green [as 别名]
def test_hang(testdir):
p = py.path.local(__file__).dirpath("conftest.py")
p.copy(testdir.tmpdir.join(p.basename))
testdir.makepyfile(
"""
import pytest
from eventlet.green import time
@pytest.mark.timeout(0.01)
def test_hang():
time.sleep(3.0)
"""
)
result = testdir.runpytest()
assert "failed to timeout" not in result.stdout.str()
result.stdout.fnmatch_lines(["*Timeout: 0.01*"])
示例4: _single_run
# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import green [as 别名]
def _single_run(self, application, sock):
"""Start a WSGI server in a new green thread."""
LOG.info("Starting single process server")
eventlet.wsgi.server(sock, application, custom_pool=self.pool,
url_length_limit=URL_LENGTH_LIMIT,
log=self._logger, debug=cfg.CONF.debug)