[issue8831] recv and recvfrom on UDP socket do not return/throw exception after a close()

Charles-Francois Natali report at bugs.python.org
Sat Sep 25 18:37:01 CEST 2010


Charles-Francois Natali <neologix at free.fr> added the comment:

> Are you sure of that? I don't see how Python behaviour would be different to a the same program written in C. Could you write a short example written in C to prove that?

I also found this surprising, so I wroke a quick C program to test this (see attached C code), and as expected, calling close() from the main thread _doesn't_ result in recv() returning (and the socket still shows up in a "netstat -A inet -a").

Furthermore, closing a socket still in use by another thread is probably quite questionable, and close(2) man page makes it clear:
"It  is  probably  unwise to close file descriptors while they may be in use by
system calls in other threads in the same process.  Since a file descriptor
may be re-used, there are some obscure race conditions that may cause
unintended side effects."

So I'd suggest to close this issue.

----------
nosy: +neologix
Added file: http://bugs.python.org/file19012/test_socket.c

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8831>
_______________________________________


More information about the Python-bugs-list mailing list