frompythonlsfimportlsfstrArr=lsf.new_stringArray(1);# Create a new stringArray, length 1
lsf.stringArray_setitem(strArr,0,"normal");# Set its value
intp_num_queues=lsf.new_intp();# Create an int ptr
lsf.intp_assign(intp_num_queues,1);# Set the int value, which is the queue number
iflsf.lsb_init("test")>0:# LSB initialization
exit(-1);queueInfo=lsf.lsb_queueinfo(strArr,intp_num_queues,None,None,0);# Query queue info
ifqueueInfo==None:exit(0);print'queue name = %s'%queueInfo.queue;print'queue description = %s'%queueInfo.description;
1
2
3
$ python test1.py
queue name = normal
queue description = For normal low priority jobs, running only if hosts are lightly loaded.
PyObject*get_queue_info_by_name(char**name,intnum){structqueueInfoEnt*queueinfo;intnumqueues=num;intoptions=0;queueinfo=lsb_queueinfo(name,// Return queries as C queueInfoEnt*&numqueues,NULL,0,options);PyObject*result=PyList_New(numqueues);// Create PyObject * to get C returnsinti;for(i=0;i<numqueues;i++){// Save queries in a loop to resultPyObject*o=SWIG_NewPointerObj(SWIG_as_voidptr(&queueinfo[i]),SWIGTYPE_p_queueInfoEnt,0|0);PyList_SetItem(result,i,o);}returnresult;}
frompythonlsfimportlsfstrArr=lsf.new_stringArray(2)# Create a new stringArray, length 2
lsf.stringArray_setitem(strArr,0,"normal")# Set the 1st queue name
lsf.stringArray_setitem(strArr,1,"public")# Set the 2nd queue name
iflsf.lsb_init("test")>0:# LSB initialization
exit(-1);forqueueInfoEntinlsf.get_queue_info_by_name(strArr,2):# Query the queue info in batch
ifqueueInfo==None:exit(0);print'queue name = %s'%queueInfoEnt.queue;print'queue description = %s\n'%queueInfoEnt.description;
1
2
3
4
5
6
$ python test2.py
queue name = normal
queue description = For normal low priority jobs, running only if hosts are lightly loaded.
queue name = public
queue description = public queue
PyObject*get_queue_info_all(){structqueueInfoEnt*queueinfo;char*resreq;intnumqueues=0;intoptions=0;resreq="";queueinfo=lsb_queueinfo(resreq,// Return queries as C queueInfoEnt*&numqueues,NULL,0,options);PyObject*result=PyList_New(numqueues);// Create PyObject * to get C returnsinti;for(i=0;i<numqueues;i++){// Save queries in a loop to resultPyObject*o=SWIG_NewPointerObj(SWIG_as_voidptr(&queueinfo[i]),SWIGTYPE_p_queueInfoEnt,0|0);PyList_SetItem(result,i,o);}returnresult;}
测试查询所有队列
1
2
3
4
5
6
7
8
9
10
11
frompythonlsfimportlsfiflsf.lsb_init("test")>0:exit(-1)# 查询所有队列信息
forqueueInfoEntinlsf.get_queue_info_all():ifqueueInfoEnt==None:exit(0)print('queue name = %s'%queueInfoEnt.queue)print('queue description = %s\n'%queueInfoEnt.description)
1
2
3
4
5
6
7
8
9
10
11
$ python test3.py
queue name = owners
queue description = For owners of some machines. Only users listed in the HOSTSsection can submit jobs to this queue.
... ... ...
queue name = interactive
queue description = For interactive jobs only
queue name = idle
queue description = Running only if the machine is idle and very lightly loaded.
I offer specialized consulting for EDA workflows, LSF/Slurm scheduling, and design environment standardization.
Turn these insights into production-ready solutions.