Added condition for testmode in signal_handler and cookies condition in post method in api

This commit is contained in:
jai.s 2020-09-22 16:11:25 +05:30
parent 895a3ed16f
commit 38194071c6
No known key found for this signature in database
GPG Key ID: 360CFA25EFC67D12
2 changed files with 6 additions and 5 deletions

View File

@ -90,12 +90,12 @@ class StoppableXMLRPCServer(SimpleXMLRPCServer):
# pylint:disable=too-few-public-methods # pylint:disable=too-few-public-methods
allow_reuse_address = True allow_reuse_address = True
def forever(self): def serve_forever(self):
"""Start the SimpleXMLRPCServer""" """Start the SimpleXMLRPCServer"""
# pylint: disable=arguments-differ # pylint: disable=arguments-differ
while state.shutdown == 0: while state.shutdown == 0:
logger.error('before handle_request') logger.error('before handle_request')
self.serve_forever() self.handle_request()
logger.error('After handle_request') logger.error('After handle_request')
@ -165,7 +165,8 @@ class singleAPI(StoppableThread):
apiNotifyPath) apiNotifyPath)
BMConfigParser().remove_option( BMConfigParser().remove_option(
'bitmessagesettings', 'apinotifypath') 'bitmessagesettings', 'apinotifypath')
se.forever() # se._stopped = False
se.serve_forever()
class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
@ -223,6 +224,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
self.end_headers() self.end_headers()
else: else:
# got a valid XML RPC response # got a valid XML RPC response
self.cookies = []
self.send_response(200) self.send_response(200)
self.send_header("Content-type", "text/xml") self.send_header("Content-type", "text/xml")
self.send_header("Content-length", str(len(response))) self.send_header("Content-length", str(len(response)))
@ -1495,7 +1497,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
def _dispatch(self, method, params): def _dispatch(self, method, params):
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
self.cookies = []
validuser = self.APIAuthenticateClient() validuser = self.APIAuthenticateClient()
if not validuser: if not validuser:
time.sleep(2) time.sleep(2)

View File

@ -162,7 +162,7 @@ def signal_handler(signum, frame):
logger.error("Got signal %i", signum) logger.error("Got signal %i", signum)
# there are possible non-UI variants to run bitmessage # there are possible non-UI variants to run bitmessage
# which should shutdown especially test-mode # which should shutdown especially test-mode
if state.thisapp.daemon or not state.enableGUI: if state.thisapp.daemon or not state.enableGUI or state.testmode:
shutdown.doCleanShutdown() shutdown.doCleanShutdown()
else: else:
print('# Thread: {}({})'.format(thread.name, thread.ident)) print('# Thread: {}({})'.format(thread.name, thread.ident))