Example #1
0
 def run (self, conn, peer):
     self.conn = conn
     self.peer = peer
     self.stream = read_stream.sock_stream (self.conn)
     upgrade = False
     try:
         try:
             for request in request_stream (self, self.stream).gen_requests():
                 if request.bad:
                     # bad request
                     request.error (400)
                 else:
                     try:
                         handler = self.pick_handler (request)
                         if handler:
                             # XXX with_timeout() ?
                             handler.handle_request (request)
                         else:
                             request.error (404)
                         request.wait_until_done()
                     except (coro.TimeoutError, coro.Interrupted):
                         raise
                     except HTTP_Upgrade:
                         upgrade = True
                         break
                     # XXX use Exception here, avoid catch/raise of coro.TimeoutError/Interrupted?
                     except:
                         tb = coro.compact_traceback()
                         self.server.log ('error: %r request=%r tb=%r' % (self.peer, request, tb))
                         request.error (500, tb)
         except (OSError, coro.TimeoutError, coro.ClosedError):
             pass
     finally:
         if not upgrade:
             self.conn.close()
Example #2
0
 def run (self, conn, peer):
     self.conn = conn
     self.peer = peer
     self.stream = read_stream.sock_stream (self.conn)
     try:
         try:
             for request in request_stream (self, self.stream).gen_requests():
                 if request.bad:
                     # bad request
                     request.error (400)
                 else:
                     try:
                         handler = self.pick_handler (request)
                         if handler:
                             # XXX with_timeout() ?
                             handler.handle_request (request)
                         else:
                             request.error (404)
                         request.wait_until_done()
                     except (coro.TimeoutError, coro.Interrupted):
                         raise
                     except:
                         tb = coro.compact_traceback()
                         request.error (500, tb)
                         self.server.log ('error: %r request=%r tb=%r' % (self.peer, request, tb))
         except (OSError, coro.TimeoutError, coro.ClosedError):
             pass
     finally:
         self.conn.close()
Example #3
0
 def run(self):
     self.stream = read_stream.sock_stream(self.conn)
     upgrade = False
     try:
         try:
             for request in request_stream(self,
                                           self.stream).gen_requests():
                 if request.bad:
                     # bad request
                     request.error(400)
                 else:
                     try:
                         handler = self.pick_handler(request)
                         if handler:
                             # XXX with_timeout() ?
                             handler.handle_request(request)
                         else:
                             request.error(404)
                         request.wait_until_done()
                     except (coro.TimeoutError, coro.Interrupted):
                         raise
                     except HTTP_Upgrade:
                         upgrade = True
                         break
                     except Exception:
                         tb = coro.traceback_data()
                         self.server.log('error', repr(request), tb)
                         request.error(500, tb)
         except (OSError, coro.TimeoutError, coro.ClosedError):
             pass
     finally:
         if not upgrade:
             self.conn.close()
Example #4
0
 def run (self):
     self.stream = read_stream.sock_stream (self.conn)
     upgrade = False
     try:
         try:
             for request in request_stream (self, self.stream).gen_requests():
                 if request.bad:
                     # bad request
                     request.error (400)
                 else:
                     try:
                         handler = self.pick_handler (request)
                         if handler:
                             # XXX with_timeout() ?
                             handler.handle_request (request)
                         else:
                             request.error (404)
                         request.wait_until_done()
                     except (coro.TimeoutError, coro.Interrupted):
                         raise
                     except HTTP_Upgrade:
                         upgrade = True
                         break
                     except Exception:
                         tb = coro.traceback_data()
                         self.server.log ('error', repr(request), tb)
                         request.error (500, tb)
         except (OSError, coro.TimeoutError, coro.ClosedError):
             pass
     finally:
         if not upgrade:
             self.conn.close()
Example #5
0
 def run(self):
     self.stream = read_stream.sock_stream(self.conn)
     upgrade = False
     try:
         try:
             for request in request_stream(self,
                                           self.stream).gen_requests():
                 if request.bad:
                     # bad request
                     request.error(400)
                 else:
                     try:
                         handler = self.pick_handler(request)
                         if handler:
                             # XXX with_timeout() ?
                             handler.handle_request(request)
                         else:
                             request.error(404)
                         request.wait_until_done()
                     except (coro.TimeoutError, coro.Interrupted):
                         raise
                     except HTTP_Upgrade:
                         upgrade = True
                         break
                     # XXX use Exception here, avoid catch/raise of coro.TimeoutError/Interrupted?
                     except:
                         tb = coro.compact_traceback()
                         self.server.log('error: %r request=%r tb=%r' %
                                         (self.peer, request, tb))
                         request.error(500, tb)
         except (OSError, coro.TimeoutError, coro.ClosedError):
             pass
     finally:
         if not upgrade:
             self.conn.close()
Example #6
0
 def __init__ (self, conn):
     self.conn = conn
     self.peer = self.conn.getpeername()
     self.stream = sock_stream (conn)
     self.busy = False
     self.write ("waiting for set_trace()...\r\n")
     self.pdb = PdbWithQuit (self, stdin=self, stdout=self)
     LOG ('open', self.peer)