Python eventlet.green() Examples

The following are 4 code examples of eventlet.green(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module eventlet , or try the search function .
Example #1
Source File: executor.py    From forge with Apache License 2.0 5 votes vote down vote up
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()]) 
Example #2
Source File: wsgi.py    From searchlight with Apache License 2.0 5 votes vote down vote up
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) 
Example #3
Source File: conftest.py    From detox with MIT License 5 votes vote down vote up
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*"]) 
Example #4
Source File: wsgi.py    From senlin with Apache License 2.0 5 votes vote down vote up
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)