Comment 5 for bug 1849971

Revision history for this message
Olaf Seibert (rhialto) wrote :

Oh, if you close() the socket before the shutdown, it results in "OSError: [Errno 9] Bad file descriptor", so that is not what is happening.

I'll be happy to just stub out the call do shutdown() if it takes too long to find a root cause here. But maybe I found something: I stuck a pdb.set_trace() just before the shutdown(), and it seems that the socket object is not quite as expected:

(Pdb) sock
<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
(Pdb) sock._io_refs

although an attempt to simulate this still doesn't get EINVAL:

$ cat
import socket

s = socket.create_connection(("", 22))
$ python3.7
<socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('', 62722), raddr=('', 22)>
<socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>
Traceback (most recent call last):
  File "", line 7, in <module>
OSError: [Errno 9] Bad file descriptor

Another difference is proto=6 in the my test versus proto=0 in the real case.

Could the socket maybe a listening socket or something? (just wild guesswork)