Skip to content

Commit

Permalink
Fix AsyncioTelemetryManager to avoid creating a task every second (#181)
Browse files Browse the repository at this point in the history
* Fix AsyncioTelemetryManager to avoid creating a task every second

* PubNub SDK v7.4.1 release.

---------

Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com>
  • Loading branch information
seba-aln and pubnub-release-bot authored Feb 26, 2024
1 parent 4c03ecd commit 1c0378b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
13 changes: 9 additions & 4 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: python
version: 7.4.0
version: 7.4.1
schema: 1
scm: github.com/pubnub/python
sdks:
Expand All @@ -18,7 +18,7 @@ sdks:
distributions:
- distribution-type: library
distribution-repository: package
package-name: pubnub-7.4.0
package-name: pubnub-7.4.1
location: https://pypi.org/project/pubnub/
supported-platforms:
supported-operating-systems:
Expand Down Expand Up @@ -97,8 +97,8 @@ sdks:
-
distribution-type: library
distribution-repository: git release
package-name: pubnub-7.4.0
location: https://github.com/pubnub/python/releases/download/v7.4.0/pubnub-7.4.0.tar.gz
package-name: pubnub-7.4.1
location: https://github.com/pubnub/python/releases/download/v7.4.1/pubnub-7.4.1.tar.gz
supported-platforms:
supported-operating-systems:
Linux:
Expand Down Expand Up @@ -169,6 +169,11 @@ sdks:
license-url: https://github.com/aio-libs/aiohttp/blob/master/LICENSE.txt
is-required: Required
changelog:
- date: 2024-02-26
version: v7.4.1
changes:
- type: bug
text: "Fixes AsyncioTelemetryManager to avoid creating a task every second."
- date: 2024-02-08
version: v7.4.0
changes:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v7.4.1
February 26 2024

#### Fixed
- Fixes AsyncioTelemetryManager to avoid creating a task every second.

## v7.4.0
February 08 2024

Expand Down
18 changes: 11 additions & 7 deletions pubnub/pubnub_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,14 +794,18 @@ async def wait_for_presence_on(self, *channel_names):
class AsyncioTelemetryManager(TelemetryManager):
def __init__(self):
TelemetryManager.__init__(self)
self._timer = AsyncioPeriodicCallback(
self._start_clean_up_timer,
self.CLEAN_UP_INTERVAL * self.CLEAN_UP_INTERVAL_MULTIPLIER,
asyncio.get_event_loop())
self._timer.start()
self.loop = asyncio.get_event_loop()
self._schedule_next_cleanup()

async def _start_clean_up_timer(self):
def _schedule_next_cleanup(self):
self._timer = self.loop.call_later(
self.CLEAN_UP_INTERVAL * self.CLEAN_UP_INTERVAL_MULTIPLIER / 1000,
self._clean_up_schedule_next
)

def _clean_up_schedule_next(self):
self.clean_up_telemetry_data()
self._schedule_next_cleanup()

def _stop_clean_up_timer(self):
self._timer.stop()
self._timer.cancel()
2 changes: 1 addition & 1 deletion pubnub/pubnub_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

class PubNubCore:
"""A base class for PubNub Python API implementations"""
SDK_VERSION = "7.4.0"
SDK_VERSION = "7.4.1"
SDK_NAME = "PubNub-Python"

TIMESTAMP_DIVIDER = 1000
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='pubnub',
version='7.4.0',
version='7.4.1',
description='PubNub Real-time push service in the cloud',
author='PubNub',
author_email='support@pubnub.com',
Expand Down

0 comments on commit 1c0378b

Please sign in to comment.