Skip to content

Commit 7053332

Browse files
Sebastian Molendapubnub-release-bot
andauthored
Event engine/compatibility (#185)
* Fix compatibility issues between EventEngine and Asyncio subscription manager * PubNub SDK v7.4.4 release. --------- Co-authored-by: PubNub Release Bot <[email protected]>
1 parent a03a816 commit 7053332

File tree

19 files changed

+388
-227
lines changed

19 files changed

+388
-227
lines changed

.github/workflows/run-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ jobs:
7777
cp sdk-specifications/features/encryption/cryptor-module.feature tests/acceptance/encryption
7878
mkdir tests/acceptance/encryption/assets/
7979
cp sdk-specifications/features/encryption/assets/* tests/acceptance/encryption/assets/
80-
cp sdk-specifications/features/subscribe/event-engine/happy-path.feature tests/acceptance/subscribe/happy-path.feature
81-
cp sdk-specifications/features/presence/event-engine/presence-engine.feature tests/acceptance/subscribe/presence-engine.feature
80+
cp sdk-specifications/features/subscribe/event-engine/happy-path_Legacy.feature tests/acceptance/subscribe/happy-path_Legacy.feature
81+
cp sdk-specifications/features/presence/event-engine/presence-engine_Legacy.feature tests/acceptance/subscribe/presence-engine_Legacy.feature
8282
8383
sudo pip3 install -r requirements-dev.txt
8484
behave --junit tests/acceptance/pam

.pubnub.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: python
2-
version: 7.4.3
2+
version: 7.4.4
33
schema: 1
44
scm: github.com/pubnub/python
55
sdks:
@@ -18,7 +18,7 @@ sdks:
1818
distributions:
1919
- distribution-type: library
2020
distribution-repository: package
21-
package-name: pubnub-7.4.3
21+
package-name: pubnub-7.4.4
2222
location: https://pypi.org/project/pubnub/
2323
supported-platforms:
2424
supported-operating-systems:
@@ -97,8 +97,8 @@ sdks:
9797
-
9898
distribution-type: library
9999
distribution-repository: git release
100-
package-name: pubnub-7.4.3
101-
location: https://github.com/pubnub/python/releases/download/v7.4.3/pubnub-7.4.3.tar.gz
100+
package-name: pubnub-7.4.4
101+
location: https://github.com/pubnub/python/releases/download/v7.4.4/pubnub-7.4.4.tar.gz
102102
supported-platforms:
103103
supported-operating-systems:
104104
Linux:
@@ -169,6 +169,11 @@ sdks:
169169
license-url: https://github.com/aio-libs/aiohttp/blob/master/LICENSE.txt
170170
is-required: Required
171171
changelog:
172+
- date: 2024-04-10
173+
version: v7.4.4
174+
changes:
175+
- type: bug
176+
text: "Fix compatibility issues between EventEngine and Asyncio subscription manager."
172177
- date: 2024-03-28
173178
version: v7.4.3
174179
changes:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v7.4.4
2+
April 10 2024
3+
4+
#### Fixed
5+
- Fix compatibility issues between EventEngine and Asyncio subscription manager.
6+
17
## v7.4.3
28
March 28 2024
39

pubnub/event_engine/effects.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

pubnub/event_engine/models/events.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class ReconnectEvent(PNEvent):
102102
pass
103103

104104

105+
class UnsubscribeAllEvent(PNEvent):
106+
pass
107+
108+
105109
"""
106110
Presence Events
107111
"""
@@ -116,7 +120,8 @@ class HeartbeatReconnectEvent(PNEvent):
116120

117121

118122
class HeartbeatLeftAllEvent(PNEvent):
119-
pass
123+
def __init__(self, suppress_leave: bool = False) -> None:
124+
self.suppress_leave = suppress_leave
120125

121126

122127
class HeartbeatLeftEvent(PNChannelGroupsEvent):

pubnub/event_engine/models/invocations.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import List, Union
22
from pubnub.exceptions import PubNubException
3-
from pubnub.enums import PNStatusCategory
3+
from pubnub.enums import PNOperationType, PNStatusCategory
44

55

66
class PNInvocation:
@@ -90,9 +90,10 @@ def __init__(self, messages: Union[None, List[str]]) -> None:
9090

9191

9292
class EmitStatusInvocation(PNEmittableInvocation):
93-
def __init__(self, status: Union[None, PNStatusCategory]) -> None:
93+
def __init__(self, status: Union[None, PNStatusCategory], operation: Union[None, PNOperationType] = None) -> None:
9494
super().__init__()
9595
self.status = status
96+
self.operation = operation
9697

9798

9899
"""

0 commit comments

Comments
 (0)