From 7609a3ce40219cc6b82ea4d7d3f49c2ac22feb3c Mon Sep 17 00:00:00 2001 From: "jai.s" Date: Mon, 14 Sep 2020 20:03:07 +0530 Subject: [PATCH] Solved addressGeneratorQueueClass get method issue and added new apiAddressGeneratorReturnQueueQueueClass queue class --- src/class_addressGenerator.py | 26 +++++++++++++---- src/queues.py | 54 ++++++++++++++++++++++++++++++++--- 2 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/class_addressGenerator.py b/src/class_addressGenerator.py index a47db8d3..d2f76e22 100755 --- a/src/class_addressGenerator.py +++ b/src/class_addressGenerator.py @@ -38,6 +38,10 @@ class addressGenerator(StoppableThread): """A thread for creating addresses""" name = "addressGenerator" + def __init__(self): + StoppableThread.__init__(self) + self.lock = threading.Lock() + def stopThread(self): try: queues.addressGeneratorQueue.put(("stopThread", "data")) @@ -56,8 +60,6 @@ class addressGenerator(StoppableThread): # logger.info('inside the class_addressGenerator\n') # logger.info('current thread -{}'.format(threading.current_thread().name)) # logger.info('&&&&&&&&&&&&&&&&&&&&&&&') - import time - time.sleep(1) # logger.info('MMMMMMMMMMMMMMMMM33333333333333333333333333') # logger.info( # 'queues.addressGeneratorQueue.queue -{}'.format( @@ -67,14 +69,26 @@ class addressGenerator(StoppableThread): # logger.info('state.shutdown-{}'.format(state.shutdown)) # logger.info('MMMMMMMMMMMMMMMMM33333333333333333333333333') # state.shutdown = 0 + logger.error('addressGenerator addressGenerator') + logger.error('state.shutdown-{}'.format(state.shutdown)) + logger.error('--------self----{}'.format(self)) while state.shutdown == 0: - queueValue = queues.addressGeneratorQueue.get() + logger.error( + 'qqqqqqqqq1111111111111111111111111111111') + with self.lock: + queueValue = queues.addressGeneratorQueue.get() + logger.error( + 'qqqqqqqqq2222222222222222222222222222222') nonceTrialsPerByte = 0 - logger.info('$$$$$$$$$$$$ queueValue @@@@@@@@@@@-{}'.format(queueValue)) + # logger.error('$$$$$$$$$$$$ queueValue @@@@@@@@@@@-{}'.format(queueValue)) payloadLengthExtraBytes = 0 - live = True + live = True + logger.error( + 'qqqqqqqqq3333333333333333333333333333333') + logger.error( + 'qqqqqqqqq33333333333333-{}'.format(queueValue[0] )) if queueValue[0] == 'createChan': - logger.info( + logger.error( 'OOOOOOOOOOOOOOOOOOOOOOOOOOOOO') command, addressVersionNumber, streamNumber, label, \ deterministicPassphrase, live = queueValue diff --git a/src/queues.py b/src/queues.py index d70727cd..2e1e90ef 100755 --- a/src/queues.py +++ b/src/queues.py @@ -45,24 +45,70 @@ class addressGeneratorQueueClass(Queue.Queue): def __init__(self): Queue.Queue.__init__(self) + def put(self, item, block =True, timeout=None): + self.debug_file.write('---this put condition--\n') + self.debug_file.write('this put condition- ') + self.debug_file.write('Current-thread-{} \n'.format( + threading.current_thread().name)) + self.debug_file.write('Traceback-{} \n'.format( + str(traceback.print_exc()))) + self.debug_file.write('Printig the put item-{}'.format( + item)) + Queue.Queue.put(self, item, block, timeout) + self.debug_file.write('-------------------\n \n') + + + def get(self, block =True, timeout=None): + self.debug_file.write('---this get condition ---\n') + self.debug_file.write('Current-thread-{} \n '.format( + threading.current_thread().name)) + self.debug_file.write('Traceback-{} \n'.format( + str(traceback.print_exc()))) + item = Queue.Queue.get(self, block, timeout) + self.debug_file.write('Printig the get item-{}'.format( + str(item))) + self.debug_file.write('-------------------\n \n') + return item + + +class apiAddressGeneratorReturnQueueQueueClass(Queue.Queue): + + debug_file = open("/tmp/apiAddressGeneratorReturnQueue.log", "a") + + def __init__(self): + self.debug_file.write( + 'apiAddressGeneratorReturnQueueQueue started.....\n' + ) + Queue.Queue.__init__(self) + def put(self, item, block =True, timeout=None): self.debug_file.write('-------------------\n') self.debug_file.write('this put condition- ') + self.debug_file.write('@@@@@@ put 51 @@@@@@\n') self.debug_file.write(threading.current_thread().name) - self.debug_file.write(traceback.print_exc()) + self.debug_file.write('@@@@@@ put 53 @@@@@@\n') + self.debug_file.write(str(traceback.print_exc())) + self.debug_file.write('@@@@@@ put 55 @@@@@@\n') Queue.Queue.put(self, item, block, timeout) + self.debug_file.write('@@@@@@ put 57 @@@@@@\n') self.debug_file.write('-------------------\n') - def get(self, item, block =True, timeout=None): + def get(self, block =True, timeout=None): self.debug_file.write('-------------------\n') self.debug_file.write('this get condition -') + self.debug_file.write('@@@@@@ get 64 @@@@@@') self.debug_file.write(threading.current_thread().name) - self.debug_file.write(traceback.print_exc()) + self.debug_file.write('@@@@@@ get 66 @@@@@@') + self.debug_file.write(str(traceback.print_exc())) + self.debug_file.write('@@@@@@ get 68 @@@@@@') item = Queue.Queue.get(self, block, timeout) + self.debug_file.write('@@@@@@ get 70 @@@@@@') self.debug_file.write('-------------------\n') return item + + workerQueue = Queue.Queue() UISignalQueue = Queue.Queue() addressGeneratorQueue = addressGeneratorQueueClass() @@ -75,7 +121,7 @@ portCheckerQueue = Queue.Queue() receiveDataQueue = Queue.Queue() #: The address generator thread uses this queue to get information back #: to the API thread. -apiAddressGeneratorReturnQueue = Queue.Queue() +apiAddressGeneratorReturnQueue = apiAddressGeneratorReturnQueueQueueClass() #: for exceptions excQueue = Queue.Queue()