Exemplo n.º 1
0
def server():
    """accepts connections on a socket, and dispatches
    new tasks for handling the incoming requests"""
    #parent process opens socket and listens:
    server_socket = Socket.server(('localhost', HTTP_PORT), backlog=2048)
    #fork some worker processes
    for i in range(HTTP_WORKERS):
        pid = os.fork()
        if pid == 0:
            #i am a worker, accept and handle connections
            try:
                for client_socket in server_socket.accept_iter():
                    Tasklet.defer(handle, client_socket)
            finally:
                return
    #i am the parent
    while True:
        Tasklet.sleep(1.0)
Exemplo n.º 2
0
 def serve(self, endpoint):
     """Serves the application at the given *endpoint*. The *endpoint* must be a tuple (<host>, <port>)."""
     server_socket = Socket.server(endpoint)
     for client_socket in server_socket.accept_iter():
         self.handle_connection(client_socket)
Exemplo n.º 3
0
def server():
    """accepts connections on a socket, and dispatches
    new tasks for handling the incoming requests"""
    server_socket = Socket.server(('localhost', 8080))
    for client_socket in server_socket.accept_iter():
        Tasklet.defer(handle, client_socket)
Exemplo n.º 4
0
def server():
    """accepts connections on a socket, and dispatches
    new tasks for handling the incoming requests"""
    server_socket = Socket.server(('localhost', 8080))
    for client_socket in server_socket.accept_iter():
        Tasklet.defer(handle, client_socket)