File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -296,11 +296,19 @@ def _read(self):
296
296
def _try_read (self ):
297
297
self ._last_heartbeat_received_time = time .time ()
298
298
while not self .asked_to_stop :
299
+ time .sleep (self .read_interval )
299
300
if self ._pause :
300
- time .sleep (self .read_interval )
301
301
continue
302
302
303
- msg = self .pipe .receive ()
303
+ # we assign self.pipe to p and access pipe methods through p
304
+ # this is because self.pipe could be set to None at any moment (e.g. the abort process could
305
+ # stop the pipe handler at any time).
306
+ p = self .pipe
307
+ if not p :
308
+ # the pipe handler is most likely stopped, but we leave it for the while loop to decide
309
+ continue
310
+
311
+ msg = p .receive ()
304
312
now = time .time ()
305
313
306
314
if msg :
@@ -315,7 +323,7 @@ def _try_read(self):
315
323
else :
316
324
# is peer gone?
317
325
# ask the pipe for the last known active time of the peer
318
- last_peer_active_time = self . pipe .get_last_peer_active_time ()
326
+ last_peer_active_time = p .get_last_peer_active_time ()
319
327
if last_peer_active_time > self ._last_heartbeat_received_time :
320
328
self ._last_heartbeat_received_time = last_peer_active_time
321
329
@@ -331,7 +339,6 @@ def _try_read(self):
331
339
)
332
340
break
333
341
334
- time .sleep (self .read_interval )
335
342
self .reader = None
336
343
337
344
def _heartbeat (self ):
You can’t perform that action at this time.
0 commit comments