[PEAK] events.io_events.Selector question
ilja
ilja at ank-sia.com
Wed Jul 4 09:15:07 EDT 2007
Hello.
I can't get trough one type of error working with sockets and PEAK
'Selector' class.
I have a socket that is being monitored (using Selector) for 'readable'
and 'writable' state.
Event source is being obtained using binding.Make.
[cut]
readable_evt = binding.Make(lambda self:
self.selector.readable(self.socket))
writable_evt = binding.Make(lambda self:
self.selector.writable(self.socket))
[/cut]
After each event firing I subscribe object's callback to for this event
using 'addCallback' method. The cancelers for last subscribed callbacks
are being stored.
So, when i need to close socket, I first call canceler methods, and then
socket.close() method.
It just happens that sometimes my socket objects (after cancelers are
called and sockets are closed) are not being deleted from 'Selector'
socket cache. So, during next Selector's 'monitor' method iteration I
get error """(10038, 'An operation was attempted on something that is
not a socket')""" (It is being raised because my closed socket is being
given to select() function).
Because of this error PEAK reactor falls apart and application terminates.
Basically, I would like to know what I'm doing wrong and how to fix it. :)
P.S.
Traceback:
peak.events.loop[292]: Traceback (most recent call last):
peak.events.loop[292]: File
"E:\Python24\Lib\site-packages\peak\events\io_events.py", line 220, in tick
peak.events.loop[292]: doTick(exit)
peak.events.loop[292]: File
"E:\Python24\Lib\site-packages\peak\events\event_threads.py", line 225,
in tick
peak.events.loop[292]: self._appointments.pop(0)[1](self,now)
peak.events.loop[292]: File
"E:\Python24\Lib\site-packages\peak\events\event_threads.py", line 283,
in <lambda>
peak.events.loop[292]: lambda s,e: func(self,e),
self.scheduler.now() + self.delay
peak.events.loop[292]: File
"E:\Python24\Lib\site-packages\peak\events\event_threads.py", line 443,
in step
peak.events.loop[292]: return self._uncaughtError()
peak.events.loop[292]: File
"E:\Python24\Lib\site-packages\peak\events\event_threads.py", line 424,
in step
peak.events.loop[292]: for event in state.stack[-1]:
peak.events.loop[292]: File
"E:\Python24\Lib\site-packages\peak\events\io_events.py", line 306, in
monitor
peak.events.loop[292]: fr,fw,fe =
self.select(r.keys(),w.keys(),e.keys(),delay)
peak.events.loop[292]: error: (10038, 'An operation was attempted on
something that is not a socket')
P.P.S.
OS: Windows 2000
Thanks.
More information about the PEAK
mailing list