From afb3a22f998a3db82dc7bd0729f14da6ad76d2a1 Mon Sep 17 00:00:00 2001 From: "jai.s" Date: Tue, 15 Sep 2020 20:20:56 +0530 Subject: [PATCH] Solved the addressGeneratorQueue get issue in the class_addressGeneratorQueue file --- src/api.py | 4 ++-- src/class_addressGenerator.py | 11 ++++++++--- src/queues.py | 4 ++-- src/shutdown.py | 37 ++++++++++++++++++++++++++--------- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/api.py b/src/api.py index 4d084e3f..acd8d4d9 100755 --- a/src/api.py +++ b/src/api.py @@ -39,7 +39,7 @@ try: varintDecodeError ) from bmconfigparser import BMConfigParser - from debug import logger + from debug import logg from helper_ackPayload import genAckPayload from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sqlStoredProcedure from inventory import Inventory @@ -638,7 +638,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): try: queues.addressGeneratorQueue.put(( 'createChan', addressVersionNumber, streamNumber, label, - passphrase, True + passphrase.decode(), True )) logger.info( '@@@@@@@@ before printing the queueReturn @@@@@@@@@') diff --git a/src/class_addressGenerator.py b/src/class_addressGenerator.py index d2f76e22..01b63d2b 100755 --- a/src/class_addressGenerator.py +++ b/src/class_addressGenerator.py @@ -75,10 +75,15 @@ class addressGenerator(StoppableThread): while state.shutdown == 0: logger.error( 'qqqqqqqqq1111111111111111111111111111111') - with self.lock: + try: queueValue = queues.addressGeneratorQueue.get() - logger.error( - 'qqqqqqqqq2222222222222222222222222222222') + logger.error('SuccessFully Loaded') + except Exception as e: + import traceback + logger.error('Traceback-{} \n'.format( + str(traceback.format_stack()))) + logger.error('Address Genertor excepation 7777') + logger.error(e) nonceTrialsPerByte = 0 # logger.error('$$$$$$$$$$$$ queueValue @@@@@@@@@@@-{}'.format(queueValue)) payloadLengthExtraBytes = 0 diff --git a/src/queues.py b/src/queues.py index 2e1e90ef..cd165550 100755 --- a/src/queues.py +++ b/src/queues.py @@ -51,7 +51,7 @@ class addressGeneratorQueueClass(Queue.Queue): self.debug_file.write('Current-thread-{} \n'.format( threading.current_thread().name)) self.debug_file.write('Traceback-{} \n'.format( - str(traceback.print_exc()))) + str(traceback.format_stack()))) self.debug_file.write('Printig the put item-{}'.format( item)) Queue.Queue.put(self, item, block, timeout) @@ -63,7 +63,7 @@ class addressGeneratorQueueClass(Queue.Queue): self.debug_file.write('Current-thread-{} \n '.format( threading.current_thread().name)) self.debug_file.write('Traceback-{} \n'.format( - str(traceback.print_exc()))) + str(traceback.format_stack()))) item = Queue.Queue.get(self, block, timeout) self.debug_file.write('Printig the get item-{}'.format( str(item))) diff --git a/src/shutdown.py b/src/shutdown.py index 897fb07a..1bafa291 100755 --- a/src/shutdown.py +++ b/src/shutdown.py @@ -31,22 +31,24 @@ def doCleanShutdown(): Used to tell all the treads to finish work and exit. """ state.shutdown = 1 - + objectProcessorQueue.put(('checkShutdownVariable', 'no data')) for thread in threading.enumerate(): if thread.isAlive() and isinstance(thread, StoppableThread): + logger.error('!!!! thread !!! -{}'.format( + thread)) thread.stopThread() UISignalQueue.put(( 'updateStatusBar', 'Saving the knownNodes list of peers to disk...')) - logger.info('Saving knownNodes list of peers to disk') + logger.error('Saving knownNodes list of peers to disk') saveKnownNodes() - logger.info('Done saving knownNodes list of peers to disk') + logger.error('Done saving knownNodes list of peers to disk') UISignalQueue.put(( 'updateStatusBar', 'Done saving the knownNodes list of peers to disk.')) - logger.info('Flushing inventory in memory out to disk...') + logger.error('Flushing inventory in memory out to disk...') UISignalQueue.put(( 'updateStatusBar', 'Flushing inventory in memory out to disk.' @@ -65,19 +67,36 @@ def doCleanShutdown(): time.sleep(.25) for thread in threading.enumerate(): + if thread.name == 'singleAPI': + try: + logger.error('inside the shutdown try') + logger.error( + 'thread flag -{}'.format( + thread.stop._flag)) + thread.stop.set() + thread.stop.clear() + logger.error( + 'After set clear thread flag -{}'.format( + thread.stop._flag)) + # thread.stop.set() + except Exception as e: + logger.error( + '======inside the shutdown except=======' + ) + logger.error(str(e)) if ( thread is not threading.currentThread() and isinstance(thread, StoppableThread) and thread.name != 'SQL' ): - logger.debug("Waiting for thread %s", thread.name) + logger.error("Waiting for thread %s", thread.name) thread.join() # This one last useless query will guarantee that the previous flush # committed and that the # objectProcessorThread committed before we close the program. sqlQuery('SELECT address FROM subscriptions') - logger.info('Finished flushing inventory.') + logger.error('Finished flushing inventory.') sqlStoredProcedure('exit') # flush queues @@ -93,10 +112,10 @@ def doCleanShutdown(): try: if shared.thisapp.daemon or not state.enableGUI: # ..fixme:: redundant? - logger.info('Clean shutdown complete.') + logger.error('Clean shutdown complete.') shared.thisapp.cleanup() os._exit(0) # pylint: disable=protected-access except AttributeError: - logger.info('Core shutdown complete.') + logger.error('Core shutdown complete.') for thread in threading.enumerate(): - logger.debug('Thread %s still running', thread.name) + logger.error('Thread %s still running', thread.name)