New submission from Mathias Panzenböck <grosser.meister.mo...@gmx.net>:

When you open a socket._fileobject through sock.makefile('rb') or similar and 
you read blocking in one thread and close the file object from another thread 
the reading thread gets an AttributeError. This is because the close method 
sets the underlying fileobject._sock member to None and the read/readline/... 
methods call recv on this member without checking if its None. I think the 
_sock member should not be set to None at all but a flag should be set that 
this file object is closed.

For the time being I use the "bugfix" I attached and therefore do not call 
sock.makefile('rb') but FileObject(sock, 'rb'). FileObject is a subtype of 
socket._fileobject that overrides the close method and closed property.

I don't know if this bug persists in 2.7 or 3.x. I still use Fedora 12 and that 
comes with Python 2.6.2.

----------
components: Library (Lib)
files: FileObject.py
messages: 109281
nosy: panzi
priority: normal
severity: normal
status: open
title: socket._fileobject: read raises AttributeError when closed in another 
thread
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file17860/FileObject.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9156>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to