Closed fdebrus closed 4 months ago
I will catch the warning and only publish it in debug log if enabled. something like
async def refresh_listener(self):
"""Refresh the Firestore listener if token was refreshed."""
if self.watch:
try:
with warnings.catch_warnings():
warnings.simplefilter("error")
_LOGGER.debug(f"Unsubscribing old listener: {self.watch}")
self.watch.unsubscribe()
except Warning as w:
_LOGGER.debug(f"Ignored warning: {w}")
_LOGGER.debug("Re-subscribing with new token")
await self.subscribe()
OR
warnings.filterwarnings("ignore", message="Background thread did not exit.*", category=UserWarning)
Will try and publish new release if confirmed stable
Here is the debug log of google.api_core.bidi, will investigate
2024-05-09 19:22:07.847 INFO (MainThread) [google.cloud.firestore_v1.watch] RPC termination has signaled manager shutdown. 2024-05-09 19:22:07.849 DEBUG (Thread-6 (_run)) [google.api_core.bidi] Cleanly exiting request generator. 2024-05-09 19:22:07.850 DEBUG (Thread-ConsumeBidirectionalStream) [google.api_core.bidi] Call to retryable <bound method ResumableBidiRpc._recv of <google.api_core.bidi.ResumableBidiRpc object at 0x7fbb2888fd10>> caused <_MultiThreadedRendezvous of RPC that terminated with: 2024-05-09 19:22:07.850 DEBUG (Thread-ConsumeBidirectionalStream) [google.api_core.bidi] Terminating <bound method ResumableBidiRpc._recv of <google.api_core.bidi.ResumableBidiRpc object at 0x7fbb2888fd10>> due to <_MultiThreadedRendezvous of RPC that terminated with: 2024-05-09 19:22:07.851 DEBUG (Thread-ConsumeBidirectionalStream) [google.api_core.bidi] recved response. 2024-05-09 19:22:08.850 WARNING (MainThread) [google.api_core.bidi] Background thread did not exit. 2024-05-09 19:22:08.857 DEBUG (MainThread) [google.api_core.bidi] Started helper thread Thread-ConsumeBidirectionalStream 2024-05-09 19:22:08.858 INFO (Thread-ConsumeBidirectionalStream) [google.api_core.bidi] Thread-ConsumeBidirectionalStream exiting
Filtered the warning from being displayed in the log. Still investigating if this is confirmed to be safe to ignore.
The logging is coming from the BackgroundConsumer.stop method in google/api_core/bidi.py:
def stop(self):
"""Stop consuming the stream and shutdown the background thread."""
with self._operational_lock:
self._bidi_rpc.close()
if self._thread is not None:
# Resume the thread to wake it up in case it is sleeping.
self.resume()
# The daemonized thread may itself block, so don't wait
# for it longer than a second.
self._thread.join(1.0)
if self._thread.is_alive(): # pragma: NO COVER
_LOGGER.warning("Background thread did not exit.")
self._thread = None
According my various reading, this is safe to ignore.
Solved in 0.0.9b2, safe to ignore warning. Logging level set to ERROR for api_core.bidi
logger = logging.getLogger('google.api_core.bidi') logger.setLevel(logging.ERROR)
For each refresh as the watcher gets unsubcribe, a warning is generated. safe to ignore ? integration is working and token is being refreshed as it should.
Logger: google.api_core.bidi Source: custom_components/aquarite/aquarite.py:110 integration: Aquarite (documentation, issues) First occurred: 3:55:42 PM (1 occurrences) Last logged: 3:55:42 PM Background thread did not exit.