Commit fcb137b
authored
rtm_v2 api spins in infinite loop under gevent (#1246)
* Raise an exception when reading from socket and getting no data.
Returning and empty bytes object causes an infinite loop between this and the
fetch function which in some cases can cause 100% cpu utilization (this happens
under gevent). Also the exception handling here can't just return an empty bytes for the same
reason - the now dead connection cannot be replaced by code that uses this
code.
* Per https://docs.python.org/3/howto/sockets.html
No data means the other side has closed the connection:
"When a recv returns 0 bytes, it means the other side has closed (or is in the
process of closing) the connection. You will not receive any more data on this
connection. Ever. You may be able to send data successfully"1 parent e24c270 commit fcb137b
1 file changed
+12
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
117 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| |||
199 | 203 | | |
200 | 204 | | |
201 | 205 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
215 | 212 | | |
216 | 213 | | |
217 | 214 | | |
| |||
0 commit comments