~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_server.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-07-08 18:05:38 UTC
  • mfrom: (4516.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090708180538-ars9cga8c3p5tcgz
(vila) Force socket shutdown in threaded http test servers

Show diffs side-by-side

added added

removed removed

Lines of Context:
382
382
        # lying around.
383
383
        self.daemon_threads = True
384
384
 
 
385
    def process_request_thread(self, request, client_address):
 
386
        SocketServer.ThreadingTCPServer.process_request_thread(
 
387
            self, request, client_address)
 
388
        # Under some circumstances (as in bug #383920), we need to force the
 
389
        # shutdown as python delays it until gc occur otherwise and the client
 
390
        # may hang.
 
391
        try:
 
392
            # The request process has been completed, the thread is about to
 
393
            # die, let's shutdown the socket if we can.
 
394
            request.shutdown(socket.SHUT_RDWR)
 
395
        except (socket.error, select.error), e:
 
396
            if e[0] in (errno.EBADF, errno.ENOTCONN):
 
397
                # Right, the socket is already down
 
398
                pass
 
399
            else:
 
400
                raise
 
401
 
385
402
 
386
403
class HttpServer(transport.Server):
387
404
    """A test server for http transports.