CiscoUcs / ucsmsdk

Python SDK for Cisco UCSM
Other
81 stars 60 forks source link

Enable filter to support multithreaded calls #63

Closed techyragu closed 8 years ago

techyragu commented 8 years ago

This fix will let user generate in_filter expression while making calls in parallel from multiple threads.

handle.login()

def query_ls():
    mos = handle.query_classid("LsServer", filter_str='(dn, "org-root/ls-sp", type="eq")')
    for mo in mos:
        print(mo.get_class_id(), mo.dn)

def query_org():
    mos = handle.query_classid("OrgOrg", filter_str='(dn, "org-root", type="eq")')
    for mo in mos:
        print(mo.get_class_id(), mo.dn)

for i in range(1, 50):
    if i % 2 != 0:
        target = query_ls
    else:
        target = query_org

    thread = Thread(name=i, target=target)
    thread.start()

while True:
    if len(enumerate()) <= 1:
        break

handle.logout()
vvb commented 8 years ago

LGTM