File tree Expand file tree Collapse file tree 1 file changed +12
-20
lines changed
Expand file tree Collapse file tree 1 file changed +12
-20
lines changed Original file line number Diff line number Diff 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
596588def _format_output (
You can’t perform that action at this time.
0 commit comments