[Python-checkins] r88395 - python/branches/py3k/Lib/asyncore.py
giampaolo.rodola
python-checkins at python.org
Fri Feb 11 14:04:18 CET 2011
Author: giampaolo.rodola
Date: Fri Feb 11 14:04:18 2011
New Revision: 88395
Log:
asyncore: introduce a new 'closed' attribute to make sure that dispatcher gets closed only once.
In different occasions close() might be called more than once, causing problems with already disconnected sockets/dispatchers.
Modified:
python/branches/py3k/Lib/asyncore.py
Modified: python/branches/py3k/Lib/asyncore.py
==============================================================================
--- python/branches/py3k/Lib/asyncore.py (original)
+++ python/branches/py3k/Lib/asyncore.py Fri Feb 11 14:04:18 2011
@@ -220,7 +220,7 @@
connected = False
accepting = False
- closing = False
+ closed = False
addr = None
ignore_log_types = frozenset(['warning'])
@@ -393,14 +393,16 @@
raise
def close(self):
- self.connected = False
- self.accepting = False
- self.del_channel()
- try:
- self.socket.close()
- except socket.error as why:
- if why.args[0] not in (ENOTCONN, EBADF):
- raise
+ if not self.closed:
+ self.closed = True
+ self.connected = False
+ self.accepting = False
+ self.del_channel()
+ try:
+ self.socket.close()
+ except socket.error as why:
+ if why.args[0] not in (ENOTCONN, EBADF):
+ raise
# cheap inheritance, used to pass all other attribute
# references to the underlying socket object.
More information about the Python-checkins
mailing list