Python eventlet.listen() Examples
The following are 30
code examples of eventlet.listen().
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: hub.py From ryu with Apache License 2.0 | 6 votes |
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
Example #2
Source File: wsgi.py From oslo.service with Apache License 2.0 | 6 votes |
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
Example #3
Source File: eventlet_backdoor.py From oslo.service with Apache License 2.0 | 6 votes |
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)
Example #4
Source File: bottle.py From silvia-pi with MIT License | 6 votes |
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)
Example #5
Source File: api.py From galaxia with Apache License 2.0 | 6 votes |
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)
Example #6
Source File: bottle.py From warriorframework with Apache License 2.0 | 6 votes |
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)
Example #7
Source File: bottle.py From warriorframework with Apache License 2.0 | 6 votes |
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)
Example #8
Source File: bottle.py From opsbro with MIT License | 5 votes |
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
Example #9
Source File: runner.py From PokemonGo-Bot-Backup with MIT License | 5 votes |
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)
Example #10
Source File: bottle.py From malwareHunter with GNU General Public License v2.0 | 5 votes |
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
Example #11
Source File: bottle.py From malwareHunter with GNU General Public License v2.0 | 5 votes |
def run(self, handler): from meinheld import server server.listen((self.host, self.port)) server.run(handler)
Example #12
Source File: server.py From sdc-live-trainer with MIT License | 5 votes |
def start(self): self.sio = socketio.Server() self.sio.register_namespace(self) self.app = socketio.Middleware(self.sio, Flask(__name__)) eventlet.wsgi.server(eventlet.listen(('', 4567)), self.app)
Example #13
Source File: bottle.py From teye_scanner_for_book with GNU General Public License v3.0 | 5 votes |
def run(self, handler): # pragma: no cover import tornado.wsgi, tornado.httpserver, tornado.ioloop container = tornado.wsgi.WSGIContainer(handler) server = tornado.httpserver.HTTPServer(container) server.listen(port=self.port) tornado.ioloop.IOLoop.instance().start()
Example #14
Source File: bottle.py From opsbro with MIT License | 5 votes |
def run(self, handler): from meinheld import server server.listen((self.host, self.port)) server.run(handler)
Example #15
Source File: bottle.py From opsbro with MIT License | 5 votes |
def run(self, handler): # pragma: no cover import tornado.wsgi, tornado.httpserver, tornado.ioloop container = tornado.wsgi.WSGIContainer(handler) server = tornado.httpserver.HTTPServer(container) server.listen(port=self.port,address=self.host) tornado.ioloop.IOLoop.instance().start()
Example #16
Source File: bottle.py From opsbro with MIT License | 5 votes |
def run(self, handler): from eventlet import wsgi, listen try: wsgi.server(listen((self.host, self.port)), handler, log_output=(not self.quiet)) except TypeError: # Fallback, if we have old version of eventlet wsgi.server(listen((self.host, self.port)), handler)
Example #17
Source File: wsgi.py From oslo.service with Apache License 2.0 | 5 votes |
def _get_unix_socket(self, socket_file, socket_mode, backlog): sock = eventlet.listen(socket_file, family=socket.AF_UNIX, backlog=backlog) if socket_mode is not None: os.chmod(socket_file, socket_mode) LOG.info("%(name)s listening on %(socket_file)s:", {'name': self.name, 'socket_file': socket_file}) return sock
Example #18
Source File: bottle.py From contrail-server-manager with Apache License 2.0 | 5 votes |
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
Example #19
Source File: bottle.py From warriorframework with Apache License 2.0 | 5 votes |
def run(self, handler): # pragma: no cover import tornado.wsgi, tornado.httpserver, tornado.ioloop container = tornado.wsgi.WSGIContainer(handler) server = tornado.httpserver.HTTPServer(container) server.listen(port=self.port, address=self.host) tornado.ioloop.IOLoop.instance().start()
Example #20
Source File: bottle.py From teye_scanner_for_book with GNU General Public License v3.0 | 5 votes |
def run(self, handler): from eventlet import wsgi, listen try: wsgi.server(listen((self.host, self.port)), handler, log_output=(not self.quiet)) except TypeError: # Fallback, if we have old version of eventlet wsgi.server(listen((self.host, self.port)), handler)
Example #21
Source File: bottle.py From malwareHunter with GNU General Public License v2.0 | 5 votes |
def run(self, handler): # pragma: no cover import tornado.wsgi, tornado.httpserver, tornado.ioloop container = tornado.wsgi.WSGIContainer(handler) server = tornado.httpserver.HTTPServer(container) server.listen(port=self.port,address=self.host) tornado.ioloop.IOLoop.instance().start()
Example #22
Source File: bottle.py From teye_scanner_for_book with GNU General Public License v3.0 | 5 votes |
def run(self, handler): from meinheld import server server.listen((self.host, self.port)) server.run(handler)
Example #23
Source File: bottle.py From teye_scanner_for_book with GNU General Public License v3.0 | 5 votes |
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
Example #24
Source File: server.py From InfraBox with Apache License 2.0 | 5 votes |
def main(): # pragma: no cover get_env('INFRABOX_DATABASE_HOST') get_env('INFRABOX_DATABASE_USER') get_env('INFRABOX_DATABASE_PASSWORD') get_env('INFRABOX_DATABASE_PORT') get_env('INFRABOX_DATABASE_DB') wsgi.server(eventlet.listen(('0.0.0.0', 8080)), app)
Example #25
Source File: server.py From InfraBox with Apache License 2.0 | 5 votes |
def main(): # pragma: no cover get_env('INFRABOX_VERSION') get_env('INFRABOX_DATABASE_HOST') get_env('INFRABOX_DATABASE_USER') get_env('INFRABOX_DATABASE_PASSWORD') get_env('INFRABOX_DATABASE_PORT') get_env('INFRABOX_DATABASE_DB') get_env('INFRABOX_OPA_HOST') get_env('INFRABOX_OPA_PORT') get_env('INFRABOX_OPA_PUSH_INTERVAL') conn = connect_db() opa_start_push_loop() wsgi.server(eventlet.listen(('0.0.0.0', 8081)), app)
Example #26
Source File: trigger.py From InfraBox with Apache License 2.0 | 5 votes |
def main(): get_env('INFRABOX_VERSION') get_env('INFRABOX_DATABASE_DB') get_env('INFRABOX_DATABASE_USER') get_env('INFRABOX_DATABASE_PASSWORD') get_env('INFRABOX_DATABASE_HOST') get_env('INFRABOX_DATABASE_PORT') get_env('INFRABOX_GITHUB_WEBHOOK_SECRET') connect_db() # Wait until DB is ready wsgi.server(eventlet.listen(('0.0.0.0', 8080)), app)
Example #27
Source File: bottle.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def run(self, handler): from eventlet import wsgi, listen try: wsgi.server(listen((self.host, self.port)), handler, log_output=(not self.quiet)) except TypeError: # Fallback, if we have old version of eventlet wsgi.server(listen((self.host, self.port)), handler)
Example #28
Source File: bottle.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def run(self, handler): # pragma: no cover import tornado.wsgi, tornado.httpserver, tornado.ioloop container = tornado.wsgi.WSGIContainer(handler) server = tornado.httpserver.HTTPServer(container) server.listen(port=self.port) tornado.ioloop.IOLoop.instance().start()
Example #29
Source File: bottle.py From NoobSec-Toolkit with GNU General Public License v2.0 | 5 votes |
def run(self, handler): from meinheld import server server.listen((self.host, self.port)) server.run(handler)
Example #30
Source File: runner.py From PokemonGo-Bot with MIT License | 5 votes |
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)