@@ -58,11 +58,11 @@ def get_new_stop_event(self):
5858 return event
5959
6060 def calculate_reconnection_delay (self , attempts ):
61- if self .reconnection_policy is PNReconnectionPolicy .LINEAR :
61+ if self .reconnection_policy is PNReconnectionPolicy .EXPONENTIAL :
62+ delay = int (math .pow (2 , attempts - 5 * math .floor ((attempts - 1 ) / 5 )) - 1 )
63+ else :
6264 delay = self .interval
6365
64- elif self .reconnection_policy is PNReconnectionPolicy .EXPONENTIAL :
65- delay = int (math .pow (2 , attempts - 5 * math .floor ((attempts - 1 ) / 5 )) - 1 )
6666 return delay
6767
6868
@@ -88,9 +88,9 @@ async def handshake_async(self, channels, groups, stop_event, timetoken: int = 0
8888 request .timetoken (0 )
8989 response = await request .future ()
9090
91- if isinstance (response , PubNubException ):
91+ if isinstance (response , Exception ):
9292 self .logger .warning (f'Handshake failed: { str (response )} ' )
93- handshake_failure = events .HandshakeFailureEvent (str ( response ) , 1 , timetoken = timetoken )
93+ handshake_failure = events .HandshakeFailureEvent (response , 1 , timetoken = timetoken )
9494 self .event_engine .trigger (handshake_failure )
9595 elif response .status .error :
9696 self .logger .warning (f'Handshake failed: { response .status .error_data .__dict__ } ' )
@@ -292,7 +292,7 @@ async def heartbeat(self, channels, groups, stop_event):
292292 self .logger .warning (f'Heartbeat failed: { str (response )} ' )
293293 self .event_engine .trigger (events .HeartbeatFailureEvent (channels = channels , groups = groups ,
294294 reason = response .status .error_data , attempt = 1 ))
295- elif response .status .error :
295+ elif response .status and response . status .error :
296296 self .logger .warning (f'Heartbeat failed: { response .status .error_data .__dict__ } ' )
297297 self .event_engine .trigger (events .HeartbeatFailureEvent (channels = channels , groups = groups ,
298298 reason = response .status .error_data , attempt = 1 ))
@@ -427,5 +427,6 @@ def emit_message(self, invocation: invocations.EmitMessagesInvocation):
427427 def emit_status (self , invocation : invocations .EmitStatusInvocation ):
428428 pn_status = PNStatus ()
429429 pn_status .category = invocation .status
430+ pn_status .operation = invocation .operation
430431 pn_status .error = False
431432 self .pubnub ._subscription_manager ._listener_manager .announce_status (pn_status )
0 commit comments