當前位置: 首頁>>代碼示例>>Python>>正文


Python eventlet.listen方法代碼示例

本文整理匯總了Python中eventlet.listen方法的典型用法代碼示例。如果您正苦於以下問題:Python eventlet.listen方法的具體用法?Python eventlet.listen怎麽用?Python eventlet.listen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eventlet的用法示例。


在下文中一共展示了eventlet.listen方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import listen [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) 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:20,代碼來源:bottle.py

示例2: main

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import listen [as 別名]
def main():
    service.prepare_service("gapi", sys.argv)
    log.info('Completed configuration file parsing...')
    log.info('Completed logger initialization...')
    app = api.setup_app()
    log.info('Pecan app setup complete...')

    host, port = cfg.CONF.gapi.host, cfg.CONF.gapi.port

    log.info('Galaxia api server started in PID %s' % os.getpid())
    log.info('Galaxia API is now serving on http://%(host)s:%(port)s' % dict(
            host=host, port=port))
    print ('Galaxia API is now serving on http://%(host)s:%(port)s' % dict(
            host=host, port=port))

    wsgi.server(eventlet.listen((host, port)), app, log=log) 
開發者ID:WiproOpenSource,項目名稱:galaxia,代碼行數:18,代碼來源:api.py

示例3: __init__

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import listen [as 別名]
def __init__(self, listen_info, handle=None, backlog=None,
                     spawn='default', **ssl_args):
            assert backlog is None
            assert spawn == 'default'

            if ':' in listen_info[0]:
                self.server = eventlet.listen(listen_info,
                                              family=socket.AF_INET6)
            else:
                self.server = eventlet.listen(listen_info)
            if ssl_args:
                def wrap_and_handle(sock, addr):
                    ssl_args.setdefault('server_side', True)
                    handle(ssl.wrap_socket(sock, **ssl_args), addr)

                self.handle = wrap_and_handle
            else:
                self.handle = handle 
開發者ID:OpenState-SDN,項目名稱:ryu,代碼行數:20,代碼來源:hub.py

示例4: _try_open_unix_domain_socket

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import listen [as 別名]
def _try_open_unix_domain_socket(socket_path):
    try:
        return eventlet.listen(socket_path, socket.AF_UNIX)
    except socket.error as e:
        if e.errno != errno.EADDRINUSE:
            # NOTE(harlowja): Some other non-address in use error
            # occurred, since we aren't handling those, re-raise
            # and give up...
            raise
        else:
            # Attempt to remove the file before opening it again.
            try:
                os.unlink(socket_path)
            except OSError as e:
                if e.errno != errno.ENOENT:
                    # NOTE(harlowja): File existed, but we couldn't
                    # delete it, give up...
                    raise
            return eventlet.listen(socket_path, socket.AF_UNIX) 
開發者ID:openstack,項目名稱:oslo.service,代碼行數:21,代碼來源:eventlet_backdoor.py

示例5: _get_socket

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import listen [as 別名]
def _get_socket(self, host, port, backlog):
        bind_addr = (host, port)
        # TODO(dims): eventlet's green dns/socket module does not actually
        # support IPv6 in getaddrinfo(). We need to get around this in the
        # future or monitor upstream for a fix
        try:
            info = socket.getaddrinfo(bind_addr[0],
                                      bind_addr[1],
                                      socket.AF_UNSPEC,
                                      socket.SOCK_STREAM)[0]
            family = info[0]
            bind_addr = info[-1]
        except Exception:
            family = socket.AF_INET

        try:
            sock = eventlet.listen(bind_addr, family, backlog=backlog)
        except EnvironmentError:
            LOG.error("Could not bind to %(host)s:%(port)s",
                      {'host': host, 'port': port})
            raise
        sock = self._set_socket_opts(sock)
        LOG.info("%(name)s listening on %(host)s:%(port)s",
                 {'name': self.name, 'host': host, 'port': port})
        return sock 
開發者ID:openstack,項目名稱:oslo.service,代碼行數:27,代碼來源:wsgi.py

示例6: _start_listening_blocking

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import listen [as 別名]
def _start_listening_blocking(self):
        # deploy as an eventlet WSGI server
        listener = eventlet.listen((self.host, self.port))
        self.server = wsgi.server(listener, self.app, log_output=False, debug=False) 
開發者ID:PokemonGoF,項目名稱:PokemonGo-Bot,代碼行數:6,代碼來源:runner.py

示例7: route

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import listen [as 別名]
def route(self, path=None, method='GET', callback=None, name=None,
              apply=None, skip=None, **config):
        """ A decorator to bind a function to a request URL. Example::

                @app.route('/hello/:name')
                def hello(name):
                    return 'Hello %s' % name

            The ``:name`` part is a wildcard. See :class:`Router` for syntax
            details.

            :param path: Request path or a list of paths to listen to. If no
              path is specified, it is automatically generated from the
              signature of the function.
            :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of
              methods to listen to. (default: `GET`)
            :param callback: An optional shortcut to avoid the decorator
              syntax. ``route(..., callback=func)`` equals ``route(...)(func)``
            :param name: The name for this route. (default: None)
            :param apply: A decorator or plugin or a list of plugins. These are
              applied to the route callback in addition to installed plugins.
            :param skip: A list of plugins, plugin classes or names. Matching
              plugins are not installed to this route. ``True`` skips all.

            Any additional keyword arguments are stored as route-specific
            configuration and passed to plugins (see :meth:`Plugin.apply`).
        """
        if callable(path): path, callback = None, path
        plugins = makelist(apply)
        skiplist = makelist(skip)
        def decorator(callback):
            # TODO: Documentation and tests
            if isinstance(callback, basestring): callback = load(callback)
            for rule in makelist(path) or yieldroutes(callback):
                for verb in makelist(method):
                    verb = verb.upper()
                    route = Route(self, rule, verb, callback, name=name,
                                  plugins=plugins, skiplist=skiplist, **config)
                    self.add_route(route)
            return callback
        return decorator(callback) if callback else decorator 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:43,代碼來源:__init__.py

示例8: run

# 需要導入模塊: import eventlet [as 別名]
# 或者: from eventlet import listen [as 別名]
def run(self, handler):
        from meinheld import server
        server.listen((self.host, self.port))
        server.run(handler) 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:6,代碼來源:__init__.py


注:本文中的eventlet.listen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。