@@ -142,10 +142,6 @@ job_status_type job_queue_node_get_status(const job_queue_node_type *node) {
142
142
return node->job_status ;
143
143
}
144
144
145
- int job_queue_node_get_submit_attempt (const job_queue_node_type *node) {
146
- return node->submit_attempt ;
147
- }
148
-
149
145
job_queue_node_type *job_queue_node_alloc (const char *job_name,
150
146
const char *run_path,
151
147
const char *run_cmd, int argc,
@@ -201,66 +197,6 @@ void job_queue_node_set_status(job_queue_node_type *node,
201
197
return ;
202
198
}
203
199
204
- submit_status_type job_queue_node_submit_simple (job_queue_node_type *node,
205
- queue_driver_type *driver) {
206
- submit_status_type submit_status;
207
- pthread_mutex_lock (&node->data_mutex );
208
- job_queue_node_set_status (node, JOB_QUEUE_SUBMITTED);
209
- void *job_data = queue_driver_submit_job (
210
- driver, node->run_cmd , node->num_cpu , node->run_path , node->job_name ,
211
- node->argc , (const char **)node->argv );
212
-
213
- if (job_data == NULL ) {
214
- // In this case the status of the job itself will be
215
- // unmodified; i.e. it will still be WAITING, and a new attempt
216
- // to submit it will be performed in the next round.
217
- submit_status = SUBMIT_DRIVER_FAIL;
218
- logger->warning (" Failed to submit job {} (attempt {})" , node->job_name ,
219
- node->submit_attempt );
220
- pthread_mutex_unlock (&node->data_mutex );
221
- return submit_status;
222
- }
223
-
224
- logger->info (" Submitted job {} (attempt {})" , node->job_name ,
225
- node->submit_attempt );
226
-
227
- node->job_data = job_data;
228
- node->submit_attempt ++;
229
- // The status JOB_QUEUE_SUBMITTED is internal, and not exported anywhere.
230
- // The job_queue_update_status() will update this to PENDING or RUNNING at
231
- // the next call. The important difference between SUBMITTED and WAITING is
232
- // that SUBMITTED have job_data != NULL and the job_queue_node free
233
- // function must be called on it.
234
- submit_status = SUBMIT_OK;
235
- job_queue_node_set_status (node, JOB_QUEUE_SUBMITTED);
236
- pthread_mutex_unlock (&node->data_mutex );
237
- return submit_status;
238
- }
239
-
240
- bool job_queue_node_kill_simple (job_queue_node_type *node,
241
- queue_driver_type *driver) {
242
- bool result = false ;
243
- pthread_mutex_lock (&node->data_mutex );
244
- job_status_type current_status = job_queue_node_get_status (node);
245
- if (current_status & JOB_QUEUE_CAN_KILL) {
246
- // If the job is killed before it is even started no driver specific
247
- // job data has been assigned; we therefore must check the
248
- // node->job_data pointer before entering.
249
- if (node->job_data ) {
250
- queue_driver_kill_job (driver, node->job_data );
251
- queue_driver_free_job (driver, node->job_data );
252
- node->job_data = NULL ;
253
- }
254
- job_queue_node_set_status (node, JOB_QUEUE_IS_KILLED);
255
- logger->info (" job {} set to killed" , node->job_name );
256
- result = true ;
257
- } else {
258
- logger->warning (" node_kill called but cannot kill {}" , node->job_name );
259
- }
260
- pthread_mutex_unlock (&node->data_mutex );
261
- return result;
262
- }
263
-
264
200
ERT_CLIB_SUBMODULE (" queue" , m) {
265
201
using namespace py ::literals;
266
202
m.def (" _refresh_status" , [](Cwrap<job_queue_node_type> node,
@@ -316,4 +252,64 @@ ERT_CLIB_SUBMODULE("queue", m) {
316
252
return std::make_pair<int , std::optional<std::string>>(
317
253
int (current_status), std::move (error_msg));
318
254
});
255
+
256
+ m.def (" _submit" , [](Cwrap<job_queue_node_type> node,
257
+ Cwrap<queue_driver_type> driver) {
258
+ pthread_mutex_lock (&node->data_mutex );
259
+ job_queue_node_set_status (node, JOB_QUEUE_SUBMITTED);
260
+ void *job_data = queue_driver_submit_job (
261
+ driver, node->run_cmd , node->num_cpu , node->run_path ,
262
+ node->job_name , node->argc , (const char **)node->argv );
263
+
264
+ if (job_data == nullptr ) {
265
+ // In this case the status of the job itself will be
266
+ // unmodified; i.e. it will still be WAITING, and a new attempt
267
+ // to submit it will be performed in the next round.
268
+ logger->warning (" Failed to submit job {} (attempt {})" ,
269
+ node->job_name , node->submit_attempt );
270
+ pthread_mutex_unlock (&node->data_mutex );
271
+ return static_cast <int >(SUBMIT_DRIVER_FAIL);
272
+ }
273
+
274
+ logger->info (" Submitted job {} (attempt {})" , node->job_name ,
275
+ node->submit_attempt );
276
+
277
+ node->job_data = job_data;
278
+ node->submit_attempt ++;
279
+ // The status JOB_QUEUE_SUBMITTED is internal, and not exported anywhere.
280
+ // The job_queue_update_status() will update this to PENDING or RUNNING at
281
+ // the next call. The important difference between SUBMITTED and WAITING is
282
+ // that SUBMITTED have job_data != NULL and the job_queue_node free
283
+ // function must be called on it.
284
+ job_queue_node_set_status (node, JOB_QUEUE_SUBMITTED);
285
+ pthread_mutex_unlock (&node->data_mutex );
286
+ return static_cast <int >(SUBMIT_OK);
287
+ });
288
+ m.def (" _kill" ,
289
+ [](Cwrap<job_queue_node_type> node, Cwrap<queue_driver_type> driver) {
290
+ bool result = false ;
291
+ pthread_mutex_lock (&node->data_mutex );
292
+ job_status_type current_status = job_queue_node_get_status (node);
293
+ if (current_status & JOB_QUEUE_CAN_KILL) {
294
+ // If the job is killed before it is even started no driver specific
295
+ // job data has been assigned; we therefore must check the
296
+ // node->job_data pointer before entering.
297
+ if (node->job_data ) {
298
+ queue_driver_kill_job (driver, node->job_data );
299
+ queue_driver_free_job (driver, node->job_data );
300
+ node->job_data = NULL ;
301
+ }
302
+ job_queue_node_set_status (node, JOB_QUEUE_IS_KILLED);
303
+ logger->info (" job {} set to killed" , node->job_name );
304
+ result = true ;
305
+ } else {
306
+ logger->warning (" node_kill called but cannot kill {}" ,
307
+ node->job_name );
308
+ }
309
+ pthread_mutex_unlock (&node->data_mutex );
310
+ return result;
311
+ });
312
+
313
+ m.def (" _get_submit_attempt" ,
314
+ [](Cwrap<job_queue_node_type> node) { return node->submit_attempt ; });
319
315
}
0 commit comments