Getting the running jobs on an LSF cluster using python and PlatformLSF
<p>I'm trying to write a simple task manager in python that will be used to run a large number of jobs in an LSF cluster.  I'm stuck trying to determine (within a python script) the number of running jobs for a given user.  On the command line this would come from the command <code>bjobs</code>.</p>

<p>IBM <a href="https://github.com/PlatformLSF/platform-python-lsf-api" rel="nofollow">makes available</a> a python wrapper to the LSF C API.  Working with <a href="https://github.com/PlatformLSF/platform-python-lsf-api/blob/master/examples/job_submit.py" rel="nofollow">one of their examples</a> and <a href="https://www.bsc.es/support/LSF/9.1.2/api_ref/lsb_userinfo.html" rel="nofollow">some documentation</a> from a copy of the C API that I found online, I have been able to cobble together the following script.</p>

<pre class="lang-py prettyprint-override"><code>from pythonlsf import lsf
lsf.lsb_init("test")
userArr = lsf.new_stringArray(1)
lsf.stringArray_setitem(userArr, 0, 'my_username')
intp_num_users = lsf.new_intp()
lsf.intp_assign(intp_num_users, 1)
user_info = lsf.lsb_userinfo(userArr,intp_num_users)
</code></pre>

<p>The variable <code>user_info</code> has attributes <code>'numPEND'</code>, <code>'numRESERVE'</code>, <code>'numRUN'</code>, and <code>'numStartJobs'</code>, but all of these are 0.  They remain zero even when <code>bjobs</code> reports a running job.</p>

<p>Can anyone tell what I might be doing wrong in the code snippet above?  I've read through both the C and python documentation several times, but can't find an error.</p>