27
27
from ctypes import byref , c_int , create_string_buffer , pointer , POINTER , sizeof
28
28
29
29
from drmaa .const import (BLOCK_EMAIL , DEADLINE_TIME , DURATION_HLIMIT ,
30
- DURATION_SLIMIT , ERROR_PATH , INPUT_PATH , JOB_CATEGORY ,
31
- JOB_IDS_SESSION_ALL , JOB_IDS_SESSION_ANY , JOB_NAME ,
32
- JobState , JobControlAction , JobSubmissionState ,
33
- JOIN_FILES , JS_STATE , NATIVE_SPECIFICATION ,
34
- OUTPUT_PATH , REMOTE_COMMAND , SIGNAL_BUFFER , START_TIME ,
35
- status_to_string , string_to_control_action ,
36
- TIMEOUT_NO_WAIT , TIMEOUT_WAIT_FOREVER , TRANSFER_FILES ,
37
- V_ARGV , V_EMAIL , V_ENV , WCT_HLIMIT , WCT_SLIMIT , WD )
30
+ DURATION_SLIMIT , ENCODING , ERROR_PATH , INPUT_PATH ,
31
+ JOB_CATEGORY , JOB_IDS_SESSION_ALL , JOB_IDS_SESSION_ANY ,
32
+ JOB_NAME , JobState , JobControlAction ,
33
+ JobSubmissionState , JOIN_FILES , JS_STATE ,
34
+ NATIVE_SPECIFICATION , OUTPUT_PATH , REMOTE_COMMAND ,
35
+ SIGNAL_BUFFER , START_TIME , status_to_string ,
36
+ string_to_control_action , TIMEOUT_NO_WAIT ,
37
+ TIMEOUT_WAIT_FOREVER , TRANSFER_FILES , V_ARGV , V_EMAIL ,
38
+ V_ENV , WCT_HLIMIT , WCT_SLIMIT , WD )
38
39
from drmaa .helpers import (adapt_rusage , Attribute , attribute_names_iterator ,
39
40
BoolConverter , c , DictAttribute , IntConverter ,
40
41
run_bulk_job , SessionStringAttribute ,
@@ -376,7 +377,7 @@ def control(jobId, operation):
376
377
or jobs submitted via native utilities.
377
378
"""
378
379
if isinstance (jobId , str ):
379
- jobId = jobId .encode ()
380
+ jobId = jobId .encode (ENCODING )
380
381
c (drmaa_control , jobId , string_to_control_action (operation ))
381
382
382
383
# takes string list, num value and boolean, no return value
@@ -401,20 +402,24 @@ def synchronize(jobIds, timeout=-1, dispose=False):
401
402
data record, which includes a record of the job's consumption of
402
403
system resources during its execution and other statistical
403
404
information. If set to True, the DRM will dispose of the job's
404
- data record at the end of the synchroniize () call. If set to
405
+ data record at the end of the synchronize () call. If set to
405
406
False, the data record will be left for future access via the
406
- wait() method.
407
+ wait() method. It is the responsibility of the application to
408
+ make sure that either `synchronize()` or `wait()`is called for
409
+ every job. Not doing so creates a memory leak. Note that calling
410
+ synchronize() with dispose set to true flushes all accounting
411
+ information for all jobs in the list.
407
412
408
413
To avoid thread race conditions in multithreaded applications, the
409
414
DRMAA implementation user should explicitly synchronize this call with
410
415
any other job submission calls or control calls that may change the
411
416
number of remote jobs.
412
417
413
- If the call exits before the
414
- timeout has elapsed, all the jobs have been waited on or there was an
415
- interrupt. If the invocation exits on timeout, an ExitTimeoutException
416
- is thrown. The caller should check system time before and after this
417
- call in order to be sure of how much time has passed.
418
+ If the call exits before the timeout has elapsed, all the jobs have
419
+ been waited on or there was an interrupt. If the invocation exits on
420
+ timeout, an ExitTimeoutException is thrown. The caller should check
421
+ system time before and after this call in order to be sure of how much
422
+ time has passed.
418
423
"""
419
424
if dispose :
420
425
d = 1
@@ -461,7 +466,7 @@ def wait(jobId, timeout=-1):
461
466
jid_out = create_string_buffer (128 )
462
467
rusage = pointer (POINTER (drmaa_attr_values_t )())
463
468
if isinstance (jobId , str ):
464
- jobId = jobId .encode ()
469
+ jobId = jobId .encode (ENCODING )
465
470
c (drmaa_wait , jobId , jid_out , sizeof (jid_out ), byref (stat ), timeout ,
466
471
rusage )
467
472
res_usage = adapt_rusage (rusage )
@@ -509,7 +514,7 @@ def jobStatus(jobId):
509
514
"""
510
515
status = c_int ()
511
516
if isinstance (jobId , str ):
512
- jobId = jobId .encode ()
517
+ jobId = jobId .encode (ENCODING )
513
518
c (drmaa_job_ps , jobId , byref (status ))
514
519
return status_to_string (status .value )
515
520
0 commit comments