puka icon indicating copy to clipboard operation
puka copied to clipboard

Catch connection errors

Open majek opened this issue 13 years ago • 2 comments

This looks quite bad:

Traceback (most recent call last):
  File "./stress_amqp.py", line 104, in <module>
    main()
  File "./stress_amqp.py", line 96, in main
    client.loop(timeout=1.0)
  File "../puka/connection.py", line 247, in loop
    self.on_read()
  File "../puka/connection.py", line 67, in on_read
    r = self.sd.recv(131072)
socket.error: [Errno 104] Connection reset by peer

majek avatar Feb 10 '12 11:02 majek

I'm also unhappy with the current state of puka's socket error handling, but I'm not sure how to make it better. As the project founder, do you have any preference for how puka informs the app of socket exceptions? Should it throw exceptions from the wait() and handle_any_callbacks() functions? Or if being used with callbacks should it run the callback with a specially crafted result parameter? Any other ideas?

Just curious. :)

jmptbl avatar Jun 12 '15 21:06 jmptbl

The "wait" after connect should block until all IP's on all protocols (v4 v6) are tried out and failed. When it fails it should throw an exception, socket.error is fine.

It's just non-trivial to implement correctly.

majek avatar Jun 13 '15 10:06 majek