[Python-checkins] r84840 - python/branches/py3k/Lib/asyncore.py

giampaolo.rodola python-checkins at python.org
Wed Sep 15 23:43:47 CEST 2010


Author: giampaolo.rodola
Date: Wed Sep 15 23:43:47 2010
New Revision: 84840
Log:
Store all errors signaling a disconnection into a global frozenset to save some computation time on recv() and send().
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	Wed Sep 15 23:43:47 2010
@@ -56,6 +56,8 @@
 from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
 ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, errorcode
 
+DISCONNECTED = frozenset((ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED))
+
 try:
 socket_map
 except NameError:
@@ -364,7 +366,7 @@
 except socket.error as why:
 if why.args[0] == EWOULDBLOCK:
 return 0
- elif why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
+ elif why.args[0] in DISCONNECTED:
 self.handle_close()
 return 0
 else:
@@ -382,7 +384,7 @@
 return data
 except socket.error as why:
 # winsock sometimes throws ENOTCONN
- if why.args[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED]:
+ if why.args[0] in DISCONNECTED:
 self.handle_close()
 return b''
 else:


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /