Message87470
| Author |
josiahcarlson |
| Recipients |
MrJean1, alanmcintyre, donmez, facundobatista, giampaolo.rodola, josiahcarlson, mark.dickinson, r.david.murray |
| Date |
2009年05月08日.20:57:49 |
| SpamBayes Score |
0.0007025106 |
| Marked as misclassified |
No |
| Message-id |
<1241816270.56.0.297536045965.issue5798@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Here's an option that doesn't use .connected, which some people have
expressed distaste for.
def readwrite(obj, flags):
try:
if flags & select.POLLIN:
obj.handle_read_event()
if flags & select.POLLOUT:
obj.handle_write_event()
if flags & select.POLLPRI:
obj.handle_expt_event()
if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL):
obj.handle_close()
except socket.error, e:
if e.args[0] not in (EBADF, ECONNRESET, ENOTCONN, ESHUTDOWN,
ECONNABORTED):
obj.handle_error()
else:
obj.handle_close()
except _reraised_exceptions:
raise
except:
obj.handle_error()
It works on OS X and should work just as well on other platforms. |
|