Skip to content

Commit 87adad5

Browse files
author
Joel Collins
committed
Allow overriding Action wait time
1 parent 724e091 commit 87adad5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/labthings/view/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ class View(MethodView):
3333
These functions will allow for automated documentation generation.
3434
"""
3535

36-
endpoint = None
37-
semtype: str = None
36+
endpoint = None # Store the View endpoint for use in specs
3837

38+
# Basic view spec metadata
3939
tags: list = [] # Custom tags the user can add
40-
_cls_tags = set() # Class tags that shouldn't be removed
4140
title: None
4241

42+
# Internal
43+
_cls_tags = set() # Class tags that shouldn't be removed
44+
4345
def __init__(self, *args, **kwargs):
4446
MethodView.__init__(self, *args, **kwargs)
4547

@@ -144,6 +146,9 @@ class ActionView(View):
144146
safe: bool = False # Does the action complete WITHOUT changing the Thing state
145147
idempotent: bool = False # Can the action be performed idempotently
146148

149+
# Action handling
150+
wait_for: int = 1 # Time in seconds to wait before returning the action as pending/running
151+
147152
# Internal
148153
_cls_tags = {"actions"}
149154
_deque = Deque() # Action queue
@@ -253,7 +258,7 @@ def dispatch_request(self, *args, **kwargs):
253258

254259
# Wait up to 2 second for the action to complete or error
255260
try:
256-
task.get(block=True, timeout=1)
261+
task.get(block=True, timeout=self.wait_for)
257262
except Timeout:
258263
pass
259264

@@ -268,13 +273,15 @@ def dispatch_request(self, *args, **kwargs):
268273

269274

270275
class PropertyView(View):
276+
# Data formatting
271277
schema: Schema = None # Schema for input AND output
272278
semtype: str = None # Semantic type string
273279

274280
# Spec overrides
275281
content_type = "application/json" # Input and output contentType
276282
responses = {} # Custom responses for all interactions
277283

284+
# Internal
278285
_cls_tags = {"properties"}
279286

280287
@classmethod

0 commit comments

Comments
 (0)