Do not raise exception on close() on account of socket attribute still being None:
>>> import asyncore >>> d = asyncore.dispatcher() >>> d.close() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.4/asyncore.py", line 401, in close self.socket.close() AttributeError: 'NoneType' object has no attribute 'close' >>>
This commit is contained in:
parent
fa1b02a126
commit
a4c377cde9
|
@ -397,11 +397,12 @@ class dispatcher:
|
||||||
self.accepting = False
|
self.accepting = False
|
||||||
self.connecting = False
|
self.connecting = False
|
||||||
self.del_channel()
|
self.del_channel()
|
||||||
try:
|
if self.socket is not None:
|
||||||
self.socket.close()
|
try:
|
||||||
except OSError as why:
|
self.socket.close()
|
||||||
if why.args[0] not in (ENOTCONN, EBADF):
|
except OSError as why:
|
||||||
raise
|
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…
Reference in New Issue