Skip to content

Commit 0806ad2

Browse files
PubNub SDK v5.1.1 release.
1 parent 3ef0195 commit 0806ad2

29 files changed

+186
-159
lines changed

.pubnub.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
name: python
2-
version: 5.1.0
2+
version: 5.1.1
33
schema: 1
44
scm: github.com/pubnub/python
55
changelog:
6+
- version: v5.1.1
7+
date: Mar 29, 2021
8+
changes:
9+
-
10+
text: "Multiple community Pull Requests for Asyncio related code applied."
11+
type: bug
612
- version: v5.1.0
713
date: Mar 8, 2021
814
changes:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [v5.1.1](https://github.com/pubnub/python/releases/tag/v5.1.1)
2+
3+
[Full Changelog](https://github.com/pubnub/python/compare/v5.1.0...v5.1.1)
4+
5+
- 🐛 Multiple community Pull Requests for Asyncio related code applied.
6+
17
## [v5.1.0](https://github.com/pubnub/python/releases/tag/v5.1.0)
28

39
[Full Changelog](https://github.com/pubnub/python/compare/v5.0.1...v5.1.0)

examples/asyncio/__init__.py

Whitespace-only changes.

examples/asyncio/http/__init__.py

Whitespace-only changes.

examples/native_threads/__init__.py

Whitespace-only changes.

examples/native_threads/http/__init__.py

Whitespace-only changes.

pubnub/managers.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
logger = logging.getLogger("pubnub")
2121

2222

23-
class PublishSequenceManager(object):
23+
class PublishSequenceManager:
2424
def __init__(self, provided_max_sequence):
2525
self.max_sequence = provided_max_sequence
2626
self.next_sequence = 0
@@ -44,23 +44,13 @@ def __init__(self, initial_config):
4444
self._current_subdomain = 1
4545

4646
def get_base_path(self):
47-
if self.config.origin is not None:
47+
if self.config.origin:
4848
return self.config.origin
49-
# TODO: should CacheBusting be used?
50-
elif False:
51-
constructed_url = ("ps%s.%s" % (self._current_subdomain, BasePathManager.DEFAULT_BASE_PATH))
52-
53-
if self._current_subdomain == BasePathManager.MAX_SUBDOMAIN:
54-
self._current_subdomain = 1
55-
else:
56-
self._current_subdomain += 1
57-
58-
return constructed_url
5949
else:
6050
return "%s.%s" % (BasePathManager.DEFAULT_SUBDOMAIN, BasePathManager.DEFAULT_BASE_PATH)
6151

6252

63-
class ReconnectionManager(object):
53+
class ReconnectionManager:
6454
INTERVAL = 3
6555
MINEXPONENTIALBACKOFF = 1
6656
MAXEXPONENTIALBACKOFF = 32
@@ -99,7 +89,7 @@ def _stop_heartbeat_timer(self):
9989
self._timer = None
10090

10191

102-
class StateManager(object):
92+
class StateManager:
10393
def __init__(self):
10494
self._channels = {}
10595
self._groups = {}
@@ -186,7 +176,7 @@ def _prepare_membership_list(data_storage, presence_storage, include_presence):
186176
return response
187177

188178

189-
class ListenerManager(object):
179+
class ListenerManager:
190180
def __init__(self, pubnub_instance):
191181
self._pubnub = pubnub_instance
192182
self._listeners = []
@@ -236,7 +226,7 @@ def announce_file_message(self, file_message):
236226
callback.file(self._pubnub, file_message)
237227

238228

239-
class SubscriptionManager(object):
229+
class SubscriptionManager:
240230
__metaclass__ = ABCMeta
241231

242232
HEARTBEAT_INTERVAL_MULTIPLIER = 1000
@@ -368,7 +358,6 @@ def _handle_endpoint_call(self, raw_result, status):
368358
message.only_channel_subscription = True
369359
self._message_queue_put(message)
370360

371-
# REVIEW: is int compatible with long for Python 2
372361
self._timetoken = int(result.metadata.timetoken)
373362
self._region = int(result.metadata.region)
374363

@@ -377,7 +366,7 @@ def _register_heartbeat_timer(self):
377366
self._stop_heartbeat_timer()
378367

379368

380-
class TelemetryManager(object): # pylint: disable=W0612
369+
class TelemetryManager:
381370
TIMESTAMP_DIVIDER = 1000
382371
MAXIMUM_LATENCY_DATA_AGE = 60
383372
CLEAN_UP_INTERVAL = 1
@@ -459,6 +448,7 @@ def endpoint_name_for_operation(operation_type):
459448
PNOperationType.PNHereNowOperation: 'pres',
460449
PNOperationType.PNGetState: 'pres',
461450
PNOperationType.PNSetStateOperation: 'pres',
451+
PNOperationType.PNHeartbeatOperation: 'pres',
462452

463453
PNOperationType.PNAddChannelsToGroupOperation: 'cg',
464454
PNOperationType.PNRemoveChannelsFromGroupOperation: 'cg',
@@ -516,7 +506,7 @@ def endpoint_name_for_operation(operation_type):
516506
return endpoint
517507

518508

519-
class TokenManager(object):
509+
class TokenManager:
520510

521511
def __init__(self):
522512
self._map = {}

pubnub/pnconfiguration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self):
3939
def validate(self):
4040
assert self.uuid is None or isinstance(self.uuid, str)
4141

42-
if self.uuid is None:
42+
if not self.uuid:
4343
self.uuid = utils.uuid()
4444

4545
def scheme(self):

pubnub/pubnub.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ def _perform_heartbeat_loop(self):
217217
def heartbeat_callback(raw_result, status):
218218
heartbeat_verbosity = self._pubnub.config.heartbeat_notification_options
219219
if status.is_error:
220-
if heartbeat_verbosity == PNHeartbeatNotificationOptions.ALL or \
221-
heartbeat_verbosity == PNHeartbeatNotificationOptions.ALL:
220+
if heartbeat_verbosity in (PNHeartbeatNotificationOptions.ALL, PNHeartbeatNotificationOptions.FAILURES):
222221
self._listener_manager.announce_status(status)
223222
else:
224223
if heartbeat_verbosity == PNHeartbeatNotificationOptions.ALL:
@@ -258,10 +257,16 @@ def disconnect(self):
258257
self._stop_subscribe_loop()
259258

260259
def _start_worker(self):
261-
consumer = NativeSubscribeMessageWorker(self._pubnub, self._listener_manager,
262-
self._message_queue, self._consumer_event)
263-
self._consumer_thread = threading.Thread(target=consumer.run,
264-
name="SubscribeMessageWorker")
260+
consumer = NativeSubscribeMessageWorker(
261+
self._pubnub,
262+
self._listener_manager,
263+
self._message_queue,
264+
self._consumer_event
265+
)
266+
self._consumer_thread = threading.Thread(
267+
target=consumer.run,
268+
name="SubscribeMessageWorker"
269+
)
265270
self._consumer_thread.setDaemon(True)
266271
self._consumer_thread.start()
267272

@@ -277,7 +282,7 @@ def _start_subscribe_loop(self):
277282
def callback(raw_result, status):
278283
""" SubscribeEndpoint callback"""
279284
if status.is_error():
280-
if status is not None and status.category == PNStatusCategory.PNCancelledCategory:
285+
if status and status.category == PNStatusCategory.PNCancelledCategory:
281286
return
282287

283288
if status.category is PNStatusCategory.PNTimeoutCategory and not self._should_stop:
@@ -286,7 +291,7 @@ def callback(raw_result, status):
286291

287292
logger.error("Exception in subscribe loop: %s" % str(status.error_data.exception))
288293

289-
if status is not None and status.category == PNStatusCategory.PNAccessDeniedCategory:
294+
if status and status.category == PNStatusCategory.PNAccessDeniedCategory:
290295
status.operation = PNOperationType.PNUnsubscribeOperation
291296
self._listener_manager.announce_status(status)
292297
self.unsubscribe_all()
@@ -465,7 +470,7 @@ def reset(self):
465470
self.done_event.clear()
466471

467472

468-
class NativeTelemetryManager(TelemetryManager): # pylint: disable=W0612
473+
class NativeTelemetryManager(TelemetryManager):
469474
def store_latency(self, latency, operation_type):
470475
super(NativeTelemetryManager, self).store_latency(latency, operation_type)
471476
self.clean_up_telemetry_data()

0 commit comments

Comments
 (0)