Skip to content

Commit

Permalink
fix(worker): Prevent timeout on large validator output by waiting on …
Browse files Browse the repository at this point in the history
…process.communicate instead of exit
  • Loading branch information
nellh committed Nov 25, 2024
1 parent 4a5bf01 commit ea5407e
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions services/datalad/datalad_service/tasks/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,9 @@ def escape_ansi(text):
return ansi_escape.sub('', text)


async def run_and_decode(args, timeout, logger):
async def run_and_decode(args, logger):
"""Run a subprocess and return the JSON output."""
process = await asyncio.create_subprocess_exec(*args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
try:
await asyncio.wait_for(process.wait(), timeout=timeout)
except asyncio.TimeoutError:
logger.warning(f'Timed out while running `{" ".join(args)}`')
process.kill()

# Retrieve what we can from the process
stdout, stderr = await process.communicate()

Expand All @@ -56,7 +50,6 @@ async def validate_dataset_deno_call(dataset_path, ref, logger=logger):
['deno', 'run', '-A',
f'jsr:@bids/validator@{DENO_VALIDATOR_VERSION}',
'--json', dataset_path],
timeout=300,
logger=logger
)

Expand Down

0 comments on commit ea5407e

Please sign in to comment.