homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients pitrou, serhiy.storchaka, vstinner
Date 2016年03月21日.13:26:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458566811.77.0.320930509727.issue26590@psf.upfronthosting.co.za>
In-reply-to
Content
On the review, Antoine wrote:
"You should put this line earlier, as outputting a warning can release the GIL..."
I disagree. It's a deliberate choice to keep the socket open while logging the ResourceWarning.
Example:
---
import socket
import warnings
def show(msg):
 s = msg.source
 #s.close()
 if s.fileno() >= 0:
 print("socket open")
 else:
 print("socket closed")
 try:
 name = s.getsockname()
 except Exception as exc:
 name = str(exc)
 print("getsockname(): %r" % (name,))
warnings._showwarnmsg = show
s = socket.socket()
s = None
---
Output with sock_finalize-2.patch:
---
socket open
getsockname(): ('0.0.0.0', 0)
---
If you uncomment the s.close() (or set sock_fd to -1 in the C code):
---
socket closed
getsockname(): '[Errno 9] Bad file descriptor'
---
IMHO it's ok to give access to socket methods in the warning logger.
History
Date User Action Args
2016年03月21日 13:26:51vstinnersetrecipients: + vstinner, pitrou, serhiy.storchaka
2016年03月21日 13:26:51vstinnersetmessageid: <1458566811.77.0.320930509727.issue26590@psf.upfronthosting.co.za>
2016年03月21日 13:26:51vstinnerlinkissue26590 messages
2016年03月21日 13:26:51vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /