diff --git a/src/api.py b/src/api.py index 80e91449..fab67029 100755 --- a/src/api.py +++ b/src/api.py @@ -90,11 +90,13 @@ class StoppableXMLRPCServer(SimpleXMLRPCServer): # pylint:disable=too-few-public-methods allow_reuse_address = True - def serve_forever(self): + def forever(self): """Start the SimpleXMLRPCServer""" # pylint: disable=arguments-differ while state.shutdown == 0: - self.handle_request() + logger.error('before handle_request') + self.serve_forever() + logger.error('After handle_request') # This thread, of which there is only one, runs the API. @@ -106,14 +108,20 @@ class singleAPI(StoppableThread): def stopThread(self): super(singleAPI, self).stopThread() s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + logger.error('11111111111 stopThread 11111111 ') try: + logger.error('11111111111 stopThread 113 ') s.connect(( BMConfigParser().get('bitmessagesettings', 'apiinterface'), BMConfigParser().getint('bitmessagesettings', 'apiport') )) + logger.error('11111111111 stopThread 118 ') s.shutdown(socket.SHUT_RDWR) + logger.error('11111111111 stopThread 120 ') s.close() + logger.error('11111111111 stopThread 122 ') except BaseException: + logger.error('11111111111 stopThread except BaseException') pass def run(self): @@ -157,7 +165,7 @@ class singleAPI(StoppableThread): apiNotifyPath) BMConfigParser().remove_option( 'bitmessagesettings', 'apinotifypath') - se.serve_forever() + se.forever() class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): diff --git a/src/class_addressGenerator.py b/src/class_addressGenerator.py index 795d35fe..8006318c 100755 --- a/src/class_addressGenerator.py +++ b/src/class_addressGenerator.py @@ -129,12 +129,10 @@ class addressGenerator(StoppableThread): if payloadLengthExtraBytes == 0: payloadLengthExtraBytes = BMConfigParser().getint( 'bitmessagesettings', 'defaultpayloadlengthextrabytes') - logger.error('createRandomAddress 176') if payloadLengthExtraBytes < \ defaults.networkDefaultPayloadLengthExtraBytes: payloadLengthExtraBytes = \ defaults.networkDefaultPayloadLengthExtraBytes - logger.error('createRandomAddress 181') if command == 'createRandomAddress': queues.UISignalQueue.put(( 'updateStatusBar', "" diff --git a/src/network/threads.py b/src/network/threads.py index 9bdaa85d..a338a916 100755 --- a/src/network/threads.py +++ b/src/network/threads.py @@ -4,7 +4,7 @@ import logging import random import threading from contextlib import contextmanager - +from pybitmessage.debug import logger class StoppableThread(threading.Thread): """Base class for application threads with stopThread method""" @@ -22,6 +22,8 @@ class StoppableThread(threading.Thread): def stopThread(self): """Stop the thread""" + if self.name == 'singleAPI': + logger.error('yes inside the the stopthread') self._stopped = True self.stop.set() diff --git a/src/shutdown.py b/src/shutdown.py index d36799e7..58ddf287 100755 --- a/src/shutdown.py +++ b/src/shutdown.py @@ -35,8 +35,13 @@ def doCleanShutdown(): objectProcessorQueue.put(('checkShutdownVariable', 'no data')) for thread in threading.enumerate(): + # if thread.name == 'singleAPI': if thread.isAlive() and isinstance(thread, StoppableThread): + # logger.error('printing the stop thread -{}'.format( + # thread)) thread.stopThread() + logger.error('thread name -{} thread._is_stopped {}'.format( + thread.name, thread._is_stopped)) UISignalQueue.put(( 'updateStatusBar',