~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: John Arbash Meinel
  • Date: 2011-09-14 12:58:17 UTC
  • mto: (6133.4.49 2.5-soft-hangup-795025)
  • mto: This revision was merged to the branch mainline in revision 6170.
  • Revision ID: john@arbash-meinel.com-20110914125817-h9csfegz6bvz93yj
It turns out that if we don't explicitly close the socket, it hangs around somewhere.

Which means that the client doesn't *know* that it has been disconnected.

Show diffs side-by-side

added added

removed removed

Lines of Context:
972
972
        data = server.read_bytes(1)
973
973
        self.assertEqual('', data)
974
974
 
 
975
    def test_socket_serve_timeout_closes_socket(self):
 
976
        server_sock, client_sock = self.portable_socket_pair()
 
977
        server = medium.SmartServerSocketStreamMedium(
 
978
            server_sock, None)
 
979
        # This should timeout quickly, and then close the connection so that
 
980
        # client_sock recv doesn't block.
 
981
        server._stream_medium_timeout = 0.1
 
982
        self.assertRaises(errors.ConnectionTimeout, server.serve)
 
983
        self.assertEqual('', client_sock.recv(1))
 
984
 
975
985
    def test_pipe_wait_for_bytes_with_timeout_with_data(self):
976
986
        # We intentionally use a real pipe here, so that we can 'select' on it.
977
987
        # You can't select() on a StringIO