Skip to content

Commit

Permalink
Generate target string before applying request context
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Collins committed Apr 24, 2020
1 parent ea68ea7 commit dbaff52
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions labthings/core/tasks/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ def __init__(self, target, *args, **kwargs):
self._args = args
self._kwargs = kwargs

# Nice string representation of target function
self.target_string = f"{self._target}(args={self._args}, kwargs={self._kwargs})"

# copy_current_request_context allows threads to access flask current_app
if has_request_context():
logging.debug(f"Copying request context to {self._target}")
self._target = copy_current_request_context(self._target)
else:
logging.debug("No request context to copy")

# Nice string representation of target function
self.target_string = f"{self._target}(args={self._args}, kwargs={self._kwargs})"

# Private state properties
self._status: str = "idle" # Task status
self._return_value = None # Return value
Expand Down

0 comments on commit dbaff52

Please sign in to comment.