Message20798
| Author |
shane_kerr |
| Recipients |
| Date |
2004年05月13日.21:47:17 |
| SpamBayes Score |
| Marked as misclassified |
| Message-id |
| In-reply-to |
| Content |
Problem:
If the loop() function of asyncore is invoked with poll
rather than select, the function readwrite() is used
when I/O is available on a socket. However, this
function does not check for hangup - provided by POLLHUP.
If a socket is attempting to write, then POLLOUT never
gets set, so the socket hangs.
Because poll() is returning immediately, but the return
value is never used, asyncore busy-loops, consuming all
available CPU.
Possible solutions:
The easy solution is to check for POLLHUP in the
readwrite() function:
if flags & (select.POLLOUT | select.POLLHUP):
obj.handle_write_event()
This makes the poll work exactly like the select - the
application raises a socket.error set to EPIPE.
An alternate solution - possibly more graceful - is to
invoke the handle_close() method of the object:
if flags & select.POLLHUP:
obj.handle_close()
else:
if flags & select.POLLIN:
obj.handle_read_event()
if flags & select.pollout:
obj.handle_write_event()
This is incompatible with the select model, but it
means that the read and write logic is now the same for
socket hangups - handle_close() is invoked.
|
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2007年08月23日 14:21:36 | admin | link | issue953599 messages |
| 2007年08月23日 14:21:36 | admin | create |
|