From be95829ec1e6e6092501cb189390e60c17f54be2 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 29 Mar 2021 20:34:36 -1000 Subject: [PATCH 1/2] Revert pubnub reconnect workaround and update to pubnub 5.1.1 (#11) --- setup.py | 2 +- yalexs/pubnub_async.py | 20 +------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/setup.py b/setup.py index a19cca9..6c897dc 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,6 @@ "python-dateutil", "aiohttp", "aiofiles", - "pubnub>=5.1.0", + "pubnub>=5.1.1", ], ) diff --git a/yalexs/pubnub_async.py b/yalexs/pubnub_async.py index 364b771..3065cbf 100644 --- a/yalexs/pubnub_async.py +++ b/yalexs/pubnub_async.py @@ -1,6 +1,5 @@ """Connect to pubnub.""" -import asyncio import datetime import logging @@ -14,11 +13,6 @@ _LOGGER = logging.getLogger(__name__) -class PubNubTimeoutWorkaround(Exception): - # reconnects are broken in pubnub https://github.com/pubnub/python/pull/101 - pass - - class AugustPubNub(SubscribeCallback): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -102,25 +96,13 @@ def channels(self): return self._device_channels.keys() -class AugustPubNubAsyncio(PubNubAsyncio): - """A wrapper to fix reconnections.""" - - async def _request_helper(self, options_func, cancellation_event): - """Wrap _request_helper to convert the timeout into PNUnknownCategory.""" - try: - return await super()._request_helper(options_func, cancellation_event) - except asyncio.TimeoutError: - # reconnects are broken in pubnub https://github.com/pubnub/python/pull/101 - raise PubNubTimeoutWorkaround # pylint: disable=raise-missing-from - - def async_create_pubnub(user_uuid, subscriptions): """Create a pubnub subscription.""" pnconfig = PNConfiguration() pnconfig.subscribe_key = AUGUST_CHANNEL pnconfig.uuid = f"pn-{str(user_uuid).upper()}" pnconfig.reconnect_policy = PNReconnectionPolicy.EXPONENTIAL - pubnub = AugustPubNubAsyncio(pnconfig) + pubnub = PubNubAsyncio(pnconfig) pubnub.add_listener(subscriptions) pubnub.subscribe().channels(subscriptions.channels).execute() From afc93f60eda6e8a9810e82582811316b7a1d6b4f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 29 Mar 2021 20:34:53 -1000 Subject: [PATCH 2/2] =?UTF-8?q?Bump=20version:=201.1.9=20=E2=86=92=201.1.1?= =?UTF-8?q?0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.cfg | 3 +-- setup.py | 2 +- yalexs/__init__.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 2b6d7ab..0acf006 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.1.9 +current_version = 1.1.10 commit = True tag = True @@ -39,4 +39,3 @@ default_section = THIRDPARTY known_first_party = homeassistant,tests forced_separate = tests combine_as_imports = true - diff --git a/setup.py b/setup.py index 6c897dc..4a22b12 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="yalexs", - version="1.1.9", + version="1.1.10", python_requires=">=3.6", classifiers=[ "Development Status :: 5 - Production/Stable", diff --git a/yalexs/__init__.py b/yalexs/__init__.py index 67836bb..f964208 100644 --- a/yalexs/__init__.py +++ b/yalexs/__init__.py @@ -1,4 +1,4 @@ """Init file for yalexs.""" __author__ = """J. Nick Koston""" __email__ = "nick@koston.org" -__version__ = "1.1.9" +__version__ = "1.1.10"