Skip to content

Commit dbaff52

Browse files
author
Joel Collins
committed
Generate target string before applying request context
1 parent ea68ea7 commit dbaff52

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

labthings/core/tasks/thread.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ def __init__(self, target, *args, **kwargs):
3333
self._args = args
3434
self._kwargs = kwargs
3535

36+
# Nice string representation of target function
37+
self.target_string = f"{self._target}(args={self._args}, kwargs={self._kwargs})"
38+
3639
# copy_current_request_context allows threads to access flask current_app
3740
if has_request_context():
3841
logging.debug(f"Copying request context to {self._target}")
3942
self._target = copy_current_request_context(self._target)
4043
else:
4144
logging.debug("No request context to copy")
4245

43-
# Nice string representation of target function
44-
self.target_string = f"{self._target}(args={self._args}, kwargs={self._kwargs})"
45-
4646
# Private state properties
4747
self._status: str = "idle" # Task status
4848
self._return_value = None # Return value

0 commit comments

Comments
 (0)