@@ -79,6 +79,7 @@ def createSocketConnection(self):
79
79
self ._sock = None
80
80
81
81
self ._sock = socket .socket ()
82
+ self ._sock .settimeout (30 )
82
83
if self ._cafile :
83
84
self ._sock = ssl .wrap_socket (
84
85
self ._sock ,
@@ -153,7 +154,11 @@ def priority_send(self, packet):
153
154
return msg_sent
154
155
155
156
def _receive_packet (self ):
156
- if not self ._poll .poll (self ._receive_timeout ):
157
+ try :
158
+ if not self ._poll .poll (self ._receive_timeout ):
159
+ return False
160
+ except Exception as err :
161
+ print ("Poll error: {0}" .format (err ))
157
162
return False
158
163
159
164
# Read message type
@@ -257,14 +262,15 @@ def _io_thread_func(self):
257
262
self ._verify_connection_state ()
258
263
259
264
self ._out_packet_mutex .acquire ()
260
- if self ._out_packet_mutex .locked () and len (self ._output_queue ) > 0 :
261
- packet = self ._output_queue [0 ]
262
- if self ._send_packet (packet ):
263
- self ._output_queue .pop (0 )
265
+ if self ._ping_failures == 0 :
266
+ if self ._out_packet_mutex .locked () and len (self ._output_queue ) > 0 :
267
+ packet = self ._output_queue [0 ]
268
+ if self ._send_packet (packet ):
269
+ self ._output_queue .pop (0 )
264
270
self ._out_packet_mutex .release ()
265
271
266
272
self ._receive_packet ()
267
273
self ._callShadowCallback ()
268
274
269
275
if len (self ._output_queue ) >= self ._draining_cutoff :
270
- time .sleep (self ._draining_interval )
276
+ time .sleep (self ._draining_interval )
0 commit comments