File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 4
4
from . import EXTENSION_NAME
5
5
6
6
7
- def current_labthing ():
7
+ def current_labthing (app = None ):
8
8
"""The LabThing instance handling current requests.
9
9
10
10
Searches for a valid LabThing extension attached to the current Flask context.
11
11
"""
12
12
# We use _get_current_object so that Task threads can still
13
13
# reach the Flask app object. Just using current_app returns
14
14
# a wrapper, which breaks it's use in Task threads
15
- app = current_app ._get_current_object () # skipcq: PYL-W0212
15
+ if not app :
16
+ app = current_app ._get_current_object () # skipcq: PYL-W0212
16
17
if not app :
17
18
return None
18
19
logging .debug ("Active app extensions:" )
19
20
logging .debug (app .extensions )
20
21
logging .debug ("Active labthing:" )
21
22
logging .debug (app .extensions [EXTENSION_NAME ])
22
- return app .extensions [ EXTENSION_NAME ]
23
+ return app .extensions . get ( EXTENSION_NAME , None )
23
24
24
25
25
26
def registered_extensions (labthing_instance = None ):
You can’t perform that action at this time.
0 commit comments