diff options
author | elie <elie> | 2013-09-21 11:41:27 +0000 |
---|---|---|
committer | elie <elie> | 2013-09-21 11:41:27 +0000 |
commit | 86c9481aabb9b5bf8b38015fc53867b00b08b2a2 (patch) | |
tree | 3012dd38f494bda5f4e09274d2f79e89d1aa76b4 /examples | |
parent | 9ed7f54b6500659183a123ed170381979970c419 (diff) | |
download | pysnmp-git-86c9481aabb9b5bf8b38015fc53867b00b08b2a2.tar.gz |
workaround for missing Queue module features at 2.4
Diffstat (limited to 'examples')
-rw-r--r-- | examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py b/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py index b49572a4..cf066e79 100644 --- a/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py +++ b/examples/hlapi/asyncore/sync/manager/cmdgen/query-agents-from-multuple-threads.py @@ -69,7 +69,8 @@ class Worker(Thread): **{ 'lookupNames': True, 'lookupValues': True } ) ) - self.requests.task_done() + if hasattr(self.requests, 'task_done'): # 2.5+ + self.requests.task_done() class ThreadPool: def __init__(self, num_threads): @@ -83,7 +84,15 @@ class ThreadPool: def getResponses(self): return self.responses - def waitCompletion(self): self.requests.join() + def waitCompletion(self): + if hasattr(self.requests, 'join'): + self.requests.join() # 2.5+ + else: + from time import sleep + # this is a lame substitute for missing .join() + # adding an explicit synchronization might be a better solution + while not self.requests.empty(): + sleep(1) pool = ThreadPool(3) |