You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/service-library/src/servicelib/aiohttp/application_setup.py
+18-29Lines changed: 18 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
importfunctools
2
2
importinspect
3
3
importlogging
4
+
importwarnings
4
5
fromcollections.abcimportCallable
5
6
fromcontextlibimportContextDecorator
6
7
fromcopyimportdeepcopy
@@ -257,42 +258,27 @@ def app_module_setup(
257
258
config_section: str|None=None,
258
259
config_enabled: str|None=None,
259
260
) ->Callable:
260
-
"""Decorator that marks a function as 'a setup function' for a given module in an application
261
-
262
-
- Marks a function as 'setup' of a given module in an application
263
-
- Ensures setup executed ONLY ONCE per app
264
-
- Addon modules:
265
-
- toggles run using 'enabled' entry in config file
266
-
- logs execution
267
-
268
-
See packages/service-library/tests/test_application_setup.py
269
-
270
-
:param module_name: typically __name__
271
-
:param depends: list of module_names that must be called first, defaults to None
272
-
:param config_section: explicit configuration section, defaults to None (i.e. the name of the module, or last entry of the name if dotted)
273
-
:param config_enabled: option in config to enable, defaults to None which is '$(module-section).enabled' (config_section and config_enabled are mutually exclusive)
274
-
:param settings_name: field name in the app's settings that corresponds to this module. Defaults to the name of the module with app prefix.
275
-
:raises DependencyError
276
-
:raises ApplicationSetupError
277
-
:return: True if setup was completed or False if setup was skipped
261
+
"""Decorator marking a function as a module setup for an application.
262
+
263
+
Ensures one-time execution and tracks setup completion. For addons, setup can be
264
+
toggled via config [deprecated] or settings.
265
+
266
+
:param settings_name: Field name in app settings for this module
267
+
:raises DependencyError: If required dependent modules are not initialized
268
+
:raises ApplicationSetupError: If setup fails
269
+
:return: True if setup completed, False if skipped
278
270
:rtype: bool
279
271
280
272
:Example:
281
-
from servicelib.aiohttp.application_setup import app_module_setup
0 commit comments