[New-bugs-announce] [issue10878] asyncore does not react properly on close()

Teodor Georgiev report at bugs.python.org
Mon Jan 10 07:40:38 CET 2011

New submission from Teodor Georgiev <lv_tokata at yahoo.com>:

I am trying to add a simple timer to each created socket and destroy it
once the timer expires:

class client(asyncore.dispatcher):
    def __init__(self,host):
    self.timeout = time.time() + 5

    def readable(self):
        if time.time() >= self.timeout:
        return True

When running that code, it raises an exception:

  File "/usr/lib/python2.6/asyncore.py", line 211, in loop
  File "/usr/lib/python2.6/asyncore.py", line 144, in poll
  File "/usr/lib/python2.6/asyncore.py", line 141, in poll
    r, w, e = select.select(r, w, e, timeout)
select.error: (9, 'Bad file descriptor')

Although del_channel is executed properly and the socket is removed from the map, the poll function is not updated with that info and continues to keep the socket into the r,w,e.

components: Library (Lib)
messages: 125882
nosy: tgeorgiev
priority: normal
severity: normal
status: open
title: asyncore does not react properly on close()
versions: Python 2.6, Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list