def get_default_hub(*a, **kw): warnings.warn( "eventlet.api.get_default_hub has moved to" " eventlet.hubs.get_default_hub", DeprecationWarning, stacklevel=2) return hubs.get_default_hub(*a, **kw)
def start(config, options): server_config = get_config_section_for_name(config, "server", options.name) if "hub_module" in server_config: hubs.use_hub(server_config.import_("hub_module")) if "fork_children" in server_config: if "prefork_listen" in server_config: _toaddr = lambda (host, port): (host, int(port)) toaddr = lambda addrstr: _toaddr(addrstr.split(":", 1)) addrs = map(toaddr, server_config["prefork_listen"].split(",")) for addr in addrs: PREFORK_SOCKETS[addr] = eventlet.listen(addr) children = server_config["fork_children"].split(",") connections = {} for i, j in enumerate(children): for k, l in enumerate(children): if i != k and (i, k) not in connections: a, b = socket.socketpair() connections[(i, k)] = (l, a) connections[(k, i)] = (j, b) for i, child in enumerate(children): print "forking", child pid = os.fork() if pid == 0: # child hub = hubs.get_hub() if hasattr(hub, "poll") and hasattr(hub.poll, "fileno"): # probably epoll which uses a filedescriptor # and thus forking without exec is bad using that # poll instance. hubs.use_hub(hubs.get_default_hub()) myconns = [] for (l, r), s in connections.items(): if l == i: myconns.append(s) else: s[1].close() options.name = child start_single(config, options, myconns) sys.exit(1) while True: try: pid, exitstatus = os.wait() print "childprocess %d died" % pid except OSError, e: if e.errno == errno.ECHILD: sys.exit(0) else: raise except KeyboardInterrupt, e: print "quitting..."
def get_default_hub(*a, **kw): warnings.warn("eventlet.api.get_default_hub has moved to" " eventlet.hubs.get_default_hub", DeprecationWarning, stacklevel=2) return hubs.get_default_hub(*a, **kw)