Question
· Jan 28

Python code Production length of queue

Is it possible to get the length of queue for a production using Python code?

I'm using embedded Python at the moment.

I'd like to use the Python external language server later - the Python external server will not start in my environment.

If it is possible to query the production queue length programmically, please advise how?

It would also be nice to show the number of messages processed per second, if IRIS keeps track of this.

Discussion (2)1
Log in or sign up to continue
import iris

GLOBAL_QUEUE = iris.gref("Ens.Queue")

def get_list_host_queue() -> dict:
    dict_queue = {}
    for composed_key, v in GLOBAL_QUEUE.query():
        host = composed_key[0]
        if host not in dict_queue:
            try:
                dict_queue[host] = v if composed_key[2] == 'count' else None
            except IndexError:
                dict_queue[host] = None
    return dict_queue

if __name__ == "__main__":
    print(get_list_host_queue())
    
# {'Ens.Actor': 0, 'Ens.Alarm': 0, 'Ens.ScheduleHandler': 0, 'EnsLib.Testing.Process': 0, 'Python.MyAsyncNGBO': 10, 'Python.MyAsyncNGBP': 0, 'SystemSignal:29404': 0, '_SyncCall:29420': 0}

Try some thing like that