Skip to content

Commit 12f856e

Browse files
committed
Fixup to timeout
1 parent aff60b6 commit 12f856e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

python/activator/activator.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# The skymap to use in the central repo
6262
skymap = os.environ["SKYMAP"]
6363
# The maximum time to spend on a single visit.
64-
global_timeout = os.environ.get("WORKER_TIMEOUT", None)
64+
global_timeout = float(os.environ.get("WORKER_TIMEOUT", 0.0))
6565
# URI to the main repository to contain processing results
6666
write_repo = os.environ["CENTRAL_REPO"]
6767
# URI to the main repository containing calibs and templates
@@ -537,14 +537,17 @@ async def _manage_process_visit(expected_visit: FannedOutVisit):
537537
This function encapsulates the use of asyncio by process_visit, while
538538
delegating all actual processing to `_process_visit_or_cancel`.
539539
"""
540-
try:
541-
async with asyncio.timeout(global_timeout): # No timeout if None
542-
await _process_visit_or_cancel(expected_visit)
543-
except TimeoutError:
544-
_log.error(f"Processing of group {expected_visit.group} detector {expected_visit.detector} "
545-
f"failed to complete in {global_timeout} s. "
546-
"Outputs have *NOT* been written.")
547-
raise
540+
if global_timeout > 0.0:
541+
try:
542+
async with asyncio.timeout(global_timeout):
543+
await _process_visit_or_cancel(expected_visit)
544+
except TimeoutError:
545+
_log.error(f"Processing of group {expected_visit.group} detector {expected_visit.detector} "
546+
f"failed to complete in {global_timeout} s. "
547+
"Outputs have *NOT* been written.")
548+
raise
549+
else:
550+
await _process_visit_or_cancel(expected_visit)
548551

549552

550553
async def _process_visit_or_cancel(expected_visit: FannedOutVisit):

0 commit comments

Comments
 (0)