Skip to content

Commit 734045e

Browse files
committed
debug run with timeout 5
1 parent b93a237 commit 734045e

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

sdgym/benchmark.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ def _score_with_timeout(
545545
synthesizer_path=None,
546546
result_writer=None,
547547
):
548-
output = {}
548+
output = {} if isinstance(result_writer, S3ResultsWriter) else None
549549
args = (
550550
synthesizer,
551551
data,
@@ -561,36 +561,28 @@ def _score_with_timeout(
561561
result_writer,
562562
)
563563
if isinstance(result_writer, S3ResultsWriter):
564-
process = threading.Thread(
565-
target=_score,
566-
args=args,
567-
daemon=True,
568-
)
569-
process.start()
570-
process.join(timeout)
571-
if process.is_alive():
564+
thread = threading.Thread(target=_score, args=args, daemon=True)
565+
thread.start()
566+
thread.join(timeout)
567+
if thread.is_alive():
572568
LOGGER.error('Timeout running %s on dataset %s;', synthesizer['name'], dataset_name)
573569
return {'timeout': True, 'error': 'Timeout'}
574570

575-
return process.result
571+
return output
576572

577573
with multiprocessing_context():
578574
with multiprocessing.Manager() as manager:
579575
output = manager.dict()
580-
process = multiprocessing.Process(
581-
target=_score,
582-
args=args,
583-
)
584-
576+
args = args[:4] + (output,) + args[5:] # replace output=None with manager.dict()
577+
process = multiprocessing.Process(target=_score, args=args)
585578
process.start()
586579
process.join(timeout)
587-
process.terminate()
588-
589-
output = dict(output)
590-
if output.get('timeout'):
580+
if process.is_alive():
591581
LOGGER.error('Timeout running %s on dataset %s;', synthesizer['name'], dataset_name)
582+
process.terminate()
583+
return {'timeout': True, 'error': 'Timeout'}
592584

593-
return output
585+
return dict(output)
594586

595587

596588
def _format_output(

0 commit comments

Comments
 (0)