Support the deprecated `poll_seconds` option on `RunnablePlugin`

This commit is contained in:
Fabio Manganiello 2023-04-01 22:02:59 +02:00
parent c23e8867e2
commit 6f237a1500
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 14 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import asyncio import asyncio
import logging import logging
import threading import threading
import warnings
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from functools import wraps from functools import wraps
@ -86,7 +87,9 @@ class RunnablePlugin(Plugin):
): ):
""" """
:param poll_interval: How often the :meth:`.loop` function should be :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 :param stop_timeout: How long we should wait for any running
threads/processes to stop before exiting (default: 5 seconds). threads/processes to stop before exiting (default: 5 seconds).
""" """
@ -97,6 +100,16 @@ class RunnablePlugin(Plugin):
self._stop_timeout = stop_timeout self._stop_timeout = stop_timeout
self._thread: Optional[threading.Thread] = None 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): def main(self):
""" """
Implementation of the main loop of the plugin. Implementation of the main loop of the plugin.