From 82b0c58a0ed64afa107145be2ad161039e6a8a3a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 8 Jun 2024 20:34:01 -0500 Subject: [PATCH] fix: allow pubnub unsub to complete since nothing currently waits (#114) --- yalexs/pubnub_async.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/yalexs/pubnub_async.py b/yalexs/pubnub_async.py index d3a8e20..9717b1a 100644 --- a/yalexs/pubnub_async.py +++ b/yalexs/pubnub_async.py @@ -1,5 +1,6 @@ """Connect to pubnub.""" +import asyncio import datetime import logging from collections.abc import Coroutine @@ -126,6 +127,9 @@ def async_create_pubnub( async def _async_unsub(): _LOGGER.debug("Removing listeners PubNub") pubnub.remove_listener(subscriptions) + _LOGGER.debug("Unsubscribing from PubNub") + pubnub.unsubscribe_all() + await asyncio.sleep(0.1) # Allow the unsubscribe to complete _LOGGER.debug("Stopping PubNub") await pubnub.stop() _LOGGER.debug("PubNub stopped")