[Stackless] Buglet in libevent-based stackless socket.
Estevo
euccastro at yahoo.com
Thu Jan 6 16:42:58 CET 2011
Hi there,
I tried to report this directly to the author of the libevent-baset stackless
socket, at the e-mail address indicated in the module (phoenix at burninglabs.com),
but my e-mail bounced. Here's hoping he's following this list.
I found a little bug in the close method of evsocket, which I thought
you might like to know about. As implemented, you can't close a socket
_unless_ the fileobject is using it when you call close():
def close(self):
# XXX Stupid workaround
# Don't close while the fileobject is still using the fakesocket
def _close():
while self.fileobject._sock == self:
stackless.schedule()
self._sock.close()
del sockets[id(self)]
if self.fileobject: # <---------
stackless.tasklet(_close)()
# So, if not self.fileobject, close() does nothing.
I suggest something like:
def close(self):
@tasklet
def _wait_and_close():
# XXX Stupid workaround
while self.fileobject._sock == self:
stackless.schedule()
_close_now()
def _close_now():
self._sock.close()
del sockets[id(self)]
if self.fileobject:
_wait_and_close()
else:
_close_now()
Regards,
Esteban.
More information about the Stackless
mailing list