New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncore incorrect failure when connection is refused and using async_chat channel #50799
Comments
When using asynchat.async_chat channel, and connection is refused, First, instead of ECONNREFUSED, you get EPIPE, second, you also get a The problem is the way asyncore detect a connect event. On the first The socket error in push will invoke the channel handle_error, which Now asyncore will invoke the channel handle_read method, which fails How should this work correctly?
I added these test to test_asyncore.py, and all of them fail with Turns out that single line change fix all the failing tests: set the With this change, when the channel try to push something to the remote The fix is tested currently only on Mac OS X 10.5. I have seen this |
The patch is tested with release26-maint and trunk. |
Tested on Ubuntu Linux 9.04. The tests will probably fail on Windows, since connection refused is |
The first fix reverted to 2.5 behavior, when self.connected is false when This fix ensure that handle_connect is called only if the socket is Tested in trunk on Mac OS X. |
This version fix also handle_expt_event, so connection refused error |
The attached patch cleans up the remnants of the "handle_expt is for |
I have a big problem with asyncore_fix_refused.patch - it assumes that a The framework should let you drop in your dispatcher class, that will What are the issues on Windows with asyncore-handle-connect-event-3.patch |
Firstly, it expects that handle_expt_event() is for handling exceptional Secondly, I pulled the part that was inside handle_expt_event() that was To respond to it being an issue that the object has a socket with a Would you be willing to try this out given my explanation as to why I |
I'll check the patch this week. The asyncore framework has low level events - handle_read_event, handle_write_event and The high level events - handle_connect, handle_accept, handle_read, handle_write, I don't see any problem in checking for errors in handle_expt_event, it works just like This design allow you do replace the dispatcher with your own dispatcher class, |
Originally, handle_expt_event() was described as "handles OOB data or In terms of "only implementing low-level stuff", this is still the case. I've updated the patch to include semantics for actually handling OOB |
I tested asyncore_fix_refused-3.patch on Mac OS X 10.5 - all asyncore There is one minor issue - _exception calls the non existing However, looking again at the code I think that it is ugly and wrong - Another issue - lately, a new event was added - handle_connect_event - |
I was wrong about handle_connect_event - it is called only from the |
This is asyncore-fix-refused-3.patch with some fixes:
Tested on Mac OS X 10.5. |
handle_expt_event was removed in the test classes because it is no In terms of "handle_expt_event should handle the low level expt event With the _exception() call as-is, it now behaves like the |
handle_expt is documented to be called when there is OOB data. However, This works exactly the same for handle_read_event and handle_write_event
If you want handle_foo_event to be called only on foo events, then they |
What's the current status of this issue? The handle_close being called twice problem is still there though, as shown in bpo-4690. Not sure what other problems remain. |
Has maintenance of asyncore effectively ceased owing to tulip/asyncio or are outstanding problems here, if any, still considered valid? |
@victor as you've been looking at other asyncore/chat issues can you look at this please? |
The latest patch was written 5 years ago, it's probably a huge work to rebase it. Giampaolo wrote that the code changed a lot since this time (especially code handling errors). asyncore-fix-refused-4.patch catchs EBADF. To me, it looks like a bug: if you get a EBADF error, we already made something wrong before. The patch doesn't call obj.handle_expt_event() anymore in _exception() if obj is not a socket. It don't understand why. I don't understand neither why _exception() now raises a new socket error instead of calling obj.handle_expt_event(). All these changes are non trivial. I don't feel able to review the patch. Sorry, I'm not interested to invest time on this deprecated module. It's time to move forward, to asyncio, and so I close this issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: