Пример #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)
Пример #2
0
 def handle(self, has_timedout = False):
     if has_timedout:
         self._stream.close()
     else:
         Tasklet.defer(self._handle_request)
Пример #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)
Пример #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)