-
-
Notifications
You must be signed in to change notification settings - Fork 411
tools, plugins: remove tools.jobs and move Job to plugins.jobs #2725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,14 +34,13 @@ | |
| jobs as plugin_jobs, | ||
| rules as plugin_rules, | ||
| ) | ||
| from sopel.tools import jobs as tools_jobs | ||
| from sopel.trigger import Trigger | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import Iterable, Mapping | ||
|
|
||
| from sopel.plugins.callables import PluginCallable | ||
| from sopel.plugins.callables import PluginCallable, PluginJob | ||
|
|
||
| from sopel.plugins.handlers import ( | ||
| AbstractPluginHandler, | ||
| PluginMetaDescription, | ||
|
|
@@ -442,7 +441,7 @@ | |
| self, | ||
| plugin: AbstractPluginHandler, | ||
| callables: Sequence[PluginCallable], | ||
| jobs: Sequence[Callable], | ||
| jobs: Sequence[PluginJob], | ||
| shutdowns: Sequence[Callable], | ||
| urls: Sequence[PluginCallable], | ||
| ) -> None: | ||
|
|
@@ -619,15 +618,11 @@ | |
| self._rules_manager.register( | ||
| plugin_rules.Rule.from_callable(self.settings, callbl)) | ||
|
|
||
| def register_jobs(self, jobs: Iterable) -> None: | ||
| def register_jobs(self, jobs: Iterable[PluginJob]) -> None: | ||
| for func in jobs: | ||
| job = tools_jobs.Job.from_callable(self.settings, func) | ||
| job = plugin_jobs.Job.from_callable(self.settings, func) | ||
| self._scheduler.register(job) | ||
|
|
||
| def unregister_jobs(self, jobs: Iterable) -> None: | ||
| for job in jobs: | ||
| self._scheduler.remove_callable_job(job) | ||
|
Comment on lines
-627
to
-629
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aaaa, removing something with no deprecation warning in a minor version 🙀 But it's not advertised in the API docs (no docstring), so… it's probably fine? 😅 |
||
|
|
||
| def register_shutdowns(self, shutdowns: Iterable) -> None: | ||
| # Append plugin's shutdown function to the bot's list of functions to | ||
| # call on shutdown | ||
|
|
@@ -1104,7 +1099,7 @@ | |
| def on_job_error( | ||
| self, | ||
| scheduler: plugin_jobs.Scheduler, | ||
| job: tools_jobs.Job, | ||
| job: plugin_jobs.Job, | ||
| exc: BaseException, | ||
| ) -> None: | ||
| """Called when a job from the Job Scheduler fails. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ | |
| from sopel import config, plugin | ||
| from sopel.irc import isupport, utils | ||
| from sopel.plugins import callables | ||
| from sopel.tools import events, jobs, SopelMemory, target | ||
| from sopel.tools import events, SopelMemory, target | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
|
|
@@ -177,15 +177,14 @@ def setup(bot: Sopel) -> None: | |
| # Manage JOIN flood protection | ||
| if bot.settings.core.throttle_join: | ||
| wait_interval = max(bot.settings.core.throttle_wait, 1) | ||
| job = jobs.Job( | ||
| [wait_interval], | ||
| plugin='coretasks', | ||
| label='throttle_join', | ||
| handler=_join_event_processing, | ||
| threaded=True, | ||
| doc=None, | ||
|
|
||
| handler = plugin.interval(wait_interval)( | ||
| plugin.label('throttle_join')( | ||
| _join_event_processing | ||
| ) | ||
| ) | ||
| bot.scheduler.register(job) | ||
| handler.plugin_name = 'coretasks' | ||
| bot.register_jobs([handler]) | ||
|
Comment on lines
+181
to
+187
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm honest, this feels a bit too "voodoo" for long-term use, even though conceptually it's just "using decorators without
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm... on one hand, yes it's just how you can use decorators. And the other hand, the PluginJob new class is not public yet, and I'm not sure it's ready to be, even tho it's probably a very simple interface to use. So... it's kinda hard to say what's best here. I also want to point out that, until the PluginJob/PluginCallable rework, you had to use |
||
|
|
||
|
|
||
| def shutdown(bot): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.