Lawouach / WebSocket-for-Python

WebSocket client and server library for Python 2 and 3 as well as PyPy (ws4py 0.5.1)
https://ws4py.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
1.12k stars 288 forks source link

Version of example that doesn't need jquery, fix IOError on resume, f… #173

Closed EternityForest closed 7 years ago

EternityForest commented 9 years ago

I added a try block around the select calls that were giving errors on resume from suspend or on dropping root, and I fixed the bug that made it not send the last message until you send another one(Issues #172 and #167, the one that only happens on SSL)

I'm not too familiar with how the parser works so this might be the wrong solution.

Hope this helps!

EternityForest commented 9 years ago

This fails test_no_bytes_read, but that can be fixed by changing the code in websocket.py once(): to

            x = self.sock.recv(4096)
            if not x:
                return False
            self.buf = self.buf + x

To make sure that reading from an empty socket always returns false, but it adds complexity.

tito commented 7 years ago

This PR solve quite many issues about stability of ws4py in case of interrupt. I'm going to rebase it and fix tests.

tito commented 7 years ago

I rewrote once() to fix unit tests, and ensure all the data is read and processed (which was not the case in your pr if the data didn't meet the number of reading_buffer_size.)