Message111333
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. |
|
Date |
User |
Action |
Args |
2010-07-23 14:33:28 | lukasz.langa | set | recipients:
+ lukasz.langa, josiahcarlson, giampaolo.rodola |
2010-07-23 14:33:28 | lukasz.langa | set | messageid: <1279895608.81.0.80539572871.issue9354@psf.upfronthosting.co.za> |
2010-07-23 14:33:26 | lukasz.langa | link | issue9354 messages |
2010-07-23 14:33:25 | lukasz.langa | create | |
|