@@ -906,17 +906,7 @@ def check_watched_items(self):
906906 def check_watched_item (self , job_state ):
907907 raise NotImplementedError ()
908908
909- def finish_job (self , job_state : AsynchronousJobState ):
910- """
911- Get the output/error for a finished job, pass to `job_wrapper.finish`
912- and cleanup all the job's temporary files.
913- """
914- galaxy_id_tag = job_state .job_wrapper .get_id_tag ()
915- external_job_id = job_state .job_id
916-
917- # To ensure that files below are readable, ownership must be reclaimed first
918- job_state .job_wrapper .reclaim_ownership ()
919-
909+ def _collect_job_output (self , job_id : int , external_job_id : Optional [str ], job_state : JobState ):
920910 # wait for the files to appear
921911 which_try = 0
922912 collect_output_success = True
@@ -930,11 +920,25 @@ def finish_job(self, job_state: AsynchronousJobState):
930920 if which_try == self .app .config .retry_job_output_collection :
931921 stdout = ""
932922 stderr = job_state .runner_states .JOB_OUTPUT_NOT_RETURNED_FROM_CLUSTER
933- log .error ("(%s/%s) %s: %s" , galaxy_id_tag , external_job_id , stderr , unicodify (e ))
923+ log .error ("(%s/%s) %s: %s" , job_id , external_job_id , stderr , unicodify (e ))
934924 collect_output_success = False
935925 else :
936926 time .sleep (1 )
937927 which_try += 1
928+ return collect_output_success , stdout , stderr
929+
930+ def finish_job (self , job_state : AsynchronousJobState ):
931+ """
932+ Get the output/error for a finished job, pass to `job_wrapper.finish`
933+ and cleanup all the job's temporary files.
934+ """
935+ galaxy_id_tag = job_state .job_wrapper .get_id_tag ()
936+ external_job_id = job_state .job_id
937+
938+ # To ensure that files below are readable, ownership must be reclaimed first
939+ job_state .job_wrapper .reclaim_ownership ()
940+
941+ collect_output_success , stdout , stderr = self ._collect_job_output (galaxy_id_tag , external_job_id , job_state )
938942
939943 if not collect_output_success :
940944 job_state .fail_message = stderr
0 commit comments