Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AsyncioTelemetryManager to avoid creating a task every second #181

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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='[email protected]',
Expand Down
Loading