From 6f237a1500f4aaf83a8b17cab88b8a08fcd6840c Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 1 Apr 2023 22:02:59 +0200 Subject: [PATCH] Support the deprecated `poll_seconds` option on `RunnablePlugin` --- platypush/plugins/__init__.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/__init__.py b/platypush/plugins/__init__.py index d4be190ccd..96d7c596f1 100644 --- a/platypush/plugins/__init__.py +++ b/platypush/plugins/__init__.py @@ -1,6 +1,7 @@ import asyncio import logging import threading +import warnings from abc import ABC, abstractmethod from functools import wraps @@ -86,7 +87,9 @@ class RunnablePlugin(Plugin): ): """ :param poll_interval: How often the :meth:`.loop` function should be - execute (default: 15 seconds). + execute (default: 15 seconds). *NOTE*: For back-compatibility + reasons, the `poll_seconds` argument is also supported, but it's + deprecated. :param stop_timeout: How long we should wait for any running threads/processes to stop before exiting (default: 5 seconds). """ @@ -97,6 +100,16 @@ class RunnablePlugin(Plugin): self._stop_timeout = stop_timeout self._thread: Optional[threading.Thread] = None + if kwargs.get('poll_seconds') is not None: + warnings.warn( + 'poll_seconds is deprecated, use poll_interval instead', + DeprecationWarning, + stacklevel=2, + ) + + if self.poll_interval is None: + self.poll_interval = kwargs['poll_seconds'] + def main(self): """ Implementation of the main loop of the plugin.