~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

[merge] Robey Pointer: Test SFTPServer absorbs EPIPE when client disappears.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import random
24
24
import re
25
25
import select
 
26
import socket
26
27
import stat
27
28
import subprocess
28
29
import sys
1030
1031
 
1031
1032
        server = paramiko.SFTPServer(FakeChannel(), 'sftp', StubServer(self), StubSFTPServer,
1032
1033
                                     root=self._root, home=self._server_homedir)
1033
 
        server.start_subsystem('sftp', None, sock)
 
1034
        try:
 
1035
            server.start_subsystem('sftp', None, sock)
 
1036
        except socket.error, e:
 
1037
            if (len(e.args) > 0) and (e.args[0] == errno.EPIPE):
 
1038
                # it's okay for the client to disconnect abruptly
 
1039
                # (bug in paramiko 1.6: it should absorb this exception)
 
1040
                pass
 
1041
            else:
 
1042
                raise
 
1043
        except Exception, e:
 
1044
            import sys; sys.stderr.write('\nEXCEPTION %r\n\n' % e.__class__)
1034
1045
        server.finish_subsystem()
1035
1046
 
1036
1047