3535class _FluxJob (Job ):
3636 def __init__ (self , * args , ** kwargs ):
3737 '''Create the flux job (and future) to watch.'''
38-
3938 super ().__init__ (* args , ** kwargs )
4039
4140 # Generate the flux job
@@ -55,10 +54,11 @@ def __init__(self, *args, **kwargs):
5554 self .fluxjob .stderr = err
5655 self .fluxjob .cwd = os .path .abspath (self .workdir )
5756 self .fluxjob .environment = dict (os .environ )
57+ self ._completed = False
5858
5959 @property
6060 def completed (self ):
61- return not self .state in WAITING_STATES
61+ return self ._completed
6262
6363
6464@register_scheduler ('flux' , error = error )
@@ -105,8 +105,9 @@ def poll(self, *jobs):
105105 # Loop through active jobs and act on status
106106 for job in jobs :
107107 if job ._flux_future .done ():
108- # The exit code can help us determine if the job was successful
109108 try :
109+ # The exit code can help us determine if the job was
110+ # successful
110111 exit_code = job ._flux_future .result (0 )
111112 except flux .job .JobException :
112113 # Currently the only state we see is cancelled here
@@ -118,13 +119,12 @@ def poll(self, *jobs):
118119 job ._state = 'SUSPENDED'
119120 else :
120121 # the job finished (but possibly with nonzero exit code)
122+ job ._state = 'COMPLETED'
121123 if exit_code != 0 :
122124 self .log (
123125 f'Job { job .jobid } did not finish successfully'
124126 )
125127
126- job ._state = 'COMPLETED'
127-
128128 job ._completed = True
129129 elif job .state in WAITING_STATES and job .max_pending_time :
130130 if time .time () - job .submit_time >= job .max_pending_time :
0 commit comments