Skip to content

Commit ccf6f86

Browse files
author
Joel Collins
committed
Read input JSON directly where available
1 parent c885f5d commit ccf6f86

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/labthings/actions/thread.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
import traceback
66
import uuid
77

8-
from flask import copy_current_request_context, has_request_context
8+
from flask import request, copy_current_request_context, has_request_context
99

1010
from ..utilities import TimeoutTracker
11-
from ..schema import LogRecordSchema
1211
from ..deque import Deque
1312

1413
_LOG = logging.getLogger(__name__)
@@ -68,8 +67,13 @@ def __init__(
6867
if has_request_context():
6968
logging.debug(f"Copying request context to {self._target}")
7069
self._target = copy_current_request_context(self._target)
70+
try:
71+
self.input = request.json
72+
except BadRequest:
73+
self.input = None
7174
else:
7275
logging.debug("No request context to copy")
76+
self.input = None
7377

7478
# Private state properties
7579
self._status: str = "pending" # Task status
@@ -79,9 +83,6 @@ def __init__(
7983
self._end_time = None # Task end time
8084

8185
# Public state properties
82-
self.input: dict = (
83-
{}
84-
) # Input arguments. TODO: Automate this. Currently manual via Action.dispatch_request
8586
self.progress: int = None # Percent progress of the task
8687
self.data = {} # Dictionary of custom data added during the task
8788
self.log = Deque(
@@ -369,9 +370,8 @@ def emit(self, record):
369370
:param record:
370371
371372
"""
372-
self.dest.append(LogRecordSchema().dump(record))
373+
self.dest.append(record)
373374
# TODO: think about whether any of the keys are security flaws
374-
# (this is why I don't dump the whole logrecord)
375375

376376

377377
# Backwards compatibility

0 commit comments

Comments
 (0)