[issue9354] fire_wrapper fails to provide getsockopt()
Łukasz Langa
report at bugs.python.org
Fri Jul 23 16:33:28 CEST 2010
New submission from Łukasz Langa <lukasz at langa.pl>:
Tested on Python 3.2a0 on Mac OS 10.6.4.
When you specify the most basic `file_dispatcher` and run the loop, `file_wrapper` fails because it doesn't provide the `getsockopt()` to fake being a socket.
The code
--------
import asyncore
import os
class FileDispatcher(asyncore.file_dispatcher):
def handle_read(self):
data = self.recv(8192)
fd = os.open('/etc/passwd', os.O_RDONLY)
s = FileDispatcher(fd)
os.close(fd)
asyncore.loop(timeout=0.01, use_poll=True, count=2)
Expected result
---------------
None, it should run OK silently.
Actual result
-------------
error: uncaptured python exception, closing channel <__main__.FileDispatcher at 0x100524e10> (<class 'AttributeError'>:'file_wrapper' object has no attribute 'getsockopt' [/opt/error-report/py3k/Lib/asyncore.py|readwrite|106] [/opt/error-report/py3k/Lib/asyncore.py|handle_write_event|449])
Traceback (most recent call last):
File "/opt/error-report/py3k/Lib/asyncore.py", line 106, in readwrite
obj.handle_write_event()
File "/opt/error-report/py3k/Lib/asyncore.py", line 449, in handle_write_event
err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
AttributeError: 'file_wrapper' object has no attribute 'getsockopt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/error-report/error_report.py", line 11, in <module>
asyncore.loop(timeout=0.01, use_poll=True, count=2)
File "/opt/error-report/py3k/Lib/asyncore.py", line 214, in loop
poll_fun(timeout, map)
File "/opt/error-report/py3k/Lib/asyncore.py", line 195, in poll2
readwrite(obj, flags)
File "/opt/error-report/py3k/Lib/asyncore.py", line 119, in readwrite
obj.handle_error()
File "/opt/error-report/py3k/Lib/asyncore.py", line 489, in handle_error
self.handle_close()
File "/opt/error-report/py3k/Lib/asyncore.py", line 508, in handle_close
self.close()
File "/opt/error-report/py3k/Lib/asyncore.py", line 396, in close
self.socket.close()
File "/opt/error-report/py3k/Lib/asyncore.py", line 617, in close
os.close(self.fd)
OSError: [Errno 9] Bad file descriptor
Patch
-----
Please find attached a patch that does add a unit test for this specific case and adds the most simple `getsockopt()` possible that is still reasonable. The patch was made with trunk r83090.
----------
components: Library (Lib)
messages: 111333
nosy: ambv, giampaolo.rodola, josiahcarlson
priority: normal
severity: normal
status: open
title: fire_wrapper fails to provide getsockopt()
type: behavior
versions: Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9354>
_______________________________________
More information about the Python-bugs-list
mailing list