mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
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.
This commit is contained in:
parent
2933312fe7
commit
42e0b7f47e
1 changed files with 11 additions and 9 deletions
|
@ -220,7 +220,7 @@ class dispatcher:
|
||||||
|
|
||||||
connected = False
|
connected = False
|
||||||
accepting = False
|
accepting = False
|
||||||
closing = False
|
closed = False
|
||||||
addr = None
|
addr = None
|
||||||
ignore_log_types = frozenset(['warning'])
|
ignore_log_types = frozenset(['warning'])
|
||||||
|
|
||||||
|
@ -393,14 +393,16 @@ class dispatcher:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.connected = False
|
if not self.closed:
|
||||||
self.accepting = False
|
self.closed = True
|
||||||
self.del_channel()
|
self.connected = False
|
||||||
try:
|
self.accepting = False
|
||||||
self.socket.close()
|
self.del_channel()
|
||||||
except socket.error as why:
|
try:
|
||||||
if why.args[0] not in (ENOTCONN, EBADF):
|
self.socket.close()
|
||||||
raise
|
except socket.error as why:
|
||||||
|
if why.args[0] not in (ENOTCONN, EBADF):
|
||||||
|
raise
|
||||||
|
|
||||||
# cheap inheritance, used to pass all other attribute
|
# cheap inheritance, used to pass all other attribute
|
||||||
# references to the underlying socket object.
|
# references to the underlying socket object.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue