Catch connection errors
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
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. :)
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.