2 ms·
The problem is that side effects are really broad and include things that are idiomatic Python. # jobs.py @scheduler.register_job(when=“daily”) def
by Spivak 4y ago
The problem is that side effects are really broad and include things that are idiomatic Python.
# jobs.py
@scheduler.register_job(when=“daily”)
def batch_job(): …
This adds the job to the global scheduler.
# models.py
class Model(DBModel):
def on_change():
# do stuff
This adds the model to the ORM’s list of modules via a metaclasss and registers its hooks.
# plugin.py
class SomePlugin(PluginBase): …
Same thing. The code to load plugins like this is just importing the module and letting the metaclass do the work.