本文整理匯總了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)