2727from ctypes import byref , c_int , create_string_buffer , pointer , POINTER , sizeof
2828
2929from 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 )
3839from drmaa .helpers import (adapt_rusage , Attribute , attribute_names_iterator ,
3940 BoolConverter , c , DictAttribute , IntConverter ,
4041 run_bulk_job , SessionStringAttribute ,
@@ -376,7 +377,7 @@ def control(jobId, operation):
376377 or jobs submitted via native utilities.
377378 """
378379 if isinstance (jobId , str ):
379- jobId = jobId .encode ()
380+ jobId = jobId .encode (ENCODING )
380381 c (drmaa_control , jobId , string_to_control_action (operation ))
381382
382383 # takes string list, num value and boolean, no return value
@@ -401,20 +402,24 @@ def synchronize(jobIds, timeout=-1, dispose=False):
401402 data record, which includes a record of the job's consumption of
402403 system resources during its execution and other statistical
403404 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
405406 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.
407412
408413 To avoid thread race conditions in multithreaded applications, the
409414 DRMAA implementation user should explicitly synchronize this call with
410415 any other job submission calls or control calls that may change the
411416 number of remote jobs.
412417
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.
418423 """
419424 if dispose :
420425 d = 1
@@ -461,7 +466,7 @@ def wait(jobId, timeout=-1):
461466 jid_out = create_string_buffer (128 )
462467 rusage = pointer (POINTER (drmaa_attr_values_t )())
463468 if isinstance (jobId , str ):
464- jobId = jobId .encode ()
469+ jobId = jobId .encode (ENCODING )
465470 c (drmaa_wait , jobId , jid_out , sizeof (jid_out ), byref (stat ), timeout ,
466471 rusage )
467472 res_usage = adapt_rusage (rusage )
@@ -509,7 +514,7 @@ def jobStatus(jobId):
509514 """
510515 status = c_int ()
511516 if isinstance (jobId , str ):
512- jobId = jobId .encode ()
517+ jobId = jobId .encode (ENCODING )
513518 c (drmaa_job_ps , jobId , byref (status ))
514519 return status_to_string (status .value )
515520
0 commit comments