There may be some race condition involved. I added a check for sock._closed, and still the EINVAL came in one case.
Code as tested:
def shutdown_socket(self, sock):
"""Properly shutdown a socket.
This should be called only when no other thread is trying to use the
socket.
"""
if not sock._closed:
try:
# import pdb; pdb.set_trace() sock.shutdown(socket.SHUT_RDWR) # fails with EINVAL sock.close()
except Exception as e: import pdb; pdb.set_trace()
if self.ignored_exceptions(e): pass else: raise
...x.test_commit.TestCommit.test_verbose_commit_with_unchanged OK 128ms
...box.test_commit.TestCommit.test_verbose_commit_with_unknown OK 281ms
..._commit.TestCommit.test_warn_about_forgotten_commit_message OK 78ms
...est_commit.TestSmartServerCommit.test_commit_to_lightweight> /home/tmp/devel/breezy/work.x86_64/breezy-3.0.1/breezy/tests/test_server.py(390)shutdown_socket()
-> if self.ignored_exceptions(e):
(Pdb) e
OSError(22, 'Invalid argument')
(Pdb) sock
<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
(Pdb) sock._closed
True
There may be some race condition involved. I added a check for sock._closed, and still the EINVAL came in one case.
Code as tested:
def shutdown_ socket( self, sock):
"""Properly shutdown a socket.
This should be called only when no other thread is trying to use the
sock. shutdown( socket. SHUT_RDWR) # fails with EINVAL
sock. close()
import pdb; pdb.set_trace() exceptions( e):
pass
else:
raise
socket.
"""
if not sock._closed:
try:
# import pdb; pdb.set_trace()
except Exception as e:
if self.ignored_
...x.test_ commit. TestCommit. test_verbose_ commit_ with_unchanged OK 128ms test_commit. TestCommit. test_verbose_ commit_ with_unknown OK 281ms TestCommit. test_warn_ about_forgotten _commit_ message OK 78ms commit. TestSmartServer Commit. test_commit_ to_lightweight> /home/tmp/ devel/breezy/ work.x86_ 64/breezy- 3.0.1/breezy/ tests/test_ server. py(390) shutdown_ socket( ) exceptions( e): AddressFamily. AF_INET, type=SocketKind .SOCK_STREAM, proto=0>
...box.
..._commit.
...est_
-> if self.ignored_
(Pdb) e
OSError(22, 'Invalid argument')
(Pdb) sock
<socket.socket [closed] fd=-1, family=
(Pdb) sock._closed
True
-Olaf.