File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -231,11 +231,15 @@ def connection_delay(self, node_id):
231
231
"""
232
232
Returns the number of milliseconds to wait, based on the connection
233
233
state, before attempting to send data. When disconnected, this respects
234
- the reconnect backoff time. When connecting or connected, this handles
235
- slow/stalled connections.
234
+ the reconnect backoff time. When connecting, returns 0 to allow
235
+ non-blocking connect to finish. When connected, returns a very large
236
+ number to handle slow/stalled connections.
236
237
237
- @param node_id The id of the node to check
238
- @return The number of milliseconds to wait.
238
+ Arguments:
239
+ node_id (int): The id of the node to check
240
+
241
+ Returns:
242
+ int: The number of milliseconds to wait.
239
243
"""
240
244
if node_id not in self ._conns :
241
245
return 0
@@ -244,6 +248,8 @@ def connection_delay(self, node_id):
244
248
time_waited_ms = time .time () - (conn .last_attempt or 0 )
245
249
if conn .state is ConnectionStates .DISCONNECTED :
246
250
return max (self .config ['reconnect_backoff_ms' ] - time_waited_ms , 0 )
251
+ elif conn .state is ConnectionStates .CONNECTING :
252
+ return 0
247
253
else :
248
254
return 999999999
249
255
You can’t perform that action at this time.
0 commit comments