File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -353,6 +353,17 @@ def _get_plugindata():
353353 continue
354354
355355 logging .info (f'Loading plugin: { plugin .name } ' )
356+
357+ """
358+ We should consider using lazy-loading instead of import_module.
359+ This line imports all .py files, which is problematic for example for tasks.
360+ If you import tasks inside an __init__, you will still need a get_component at
361+ top of tasks (to mark function as celery tasks). The get_component('celery') won't
362+ return anything, since everything is not ready yet.
363+
364+ Refactoring this code will probably be a no-go since there are many dependencies
365+ in eg the hooking system. Modules needs to be loaded
366+ """
356367 mod = import_module (plugin .name )
357368
358369 if tasks_candidate :
@@ -430,7 +441,7 @@ def get_plugin_manager() -> PluginManager:
430441
431442def get_component (name : str ):
432443 try :
433- return plugin_manager .optional_components [name ]
444+ return plugin_manager .optional_components [name ]
434445 except KeyError :
435446 raise Exception (
436447 f'Component is not defined (yet?). Defined components are: { list (plugin_manager .optional_components .keys ())} '
You can’t perform that action at this time.
0 commit comments