当前位置: 首页>>代码示例>>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;未经允许,请勿转载。