From 75fc9cb15a50f7b1c0fb04d41a042ffcd80b24c5 Mon Sep 17 00:00:00 2001 From: hv7214 Date: Fri, 31 Jan 2020 15:16:03 +0530 Subject: [PATCH 1/2] fix(components/core/server): added methods to download and kill endpoints --- components/core/Server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/core/Server.py b/components/core/Server.py index ca43be2f..dc390cf7 100644 --- a/components/core/Server.py +++ b/components/core/Server.py @@ -27,8 +27,8 @@ def serve_ui1(): # download endpoints -server.add_url_rule(rule='/download/start', endpoint='start', view_func=Download.start) -server.add_url_rule(rule='/download/kill', endpoint='kill', view_func=Download.kill) +server.add_url_rule(rule='/download/start', endpoint='start', view_func=Download.start, methods=['GET']) +server.add_url_rule(rule='/download/kill', endpoint='kill', view_func=Download.kill, methods=['GET']) server.add_url_rule(rule='/api/download', endpoint='add_download_request', view_func=Download.add_download_request, methods=['POST']) server.add_url_rule(rule='/api/download/', endpoint='remove_download_request', @@ -40,7 +40,7 @@ def serve_ui1(): server.add_url_rule(rule='/api/download/', endpoint='get_download', view_func=Download.get_download, methods=['GET']) server.add_url_rule(rule='/api/file_from_minio/', endpoint='get_file_from_minio', view_func=Download.get_file_from_minio, - methods=['GET']) + methods=['GET']) # user action api endpoints server.add_url_rule(rule='/api/login', endpoint='login', view_func=User.login, methods=['POST']) From 732cf42478cb088b753d136c514ece8c5910695e Mon Sep 17 00:00:00 2001 From: hv7214 Date: Fri, 31 Jan 2020 15:18:15 +0530 Subject: [PATCH 2/2] fix(components/core/DownloadDaemon.py): appended handler to list added log for socket close --- components/core/DownloadDaemon.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/components/core/DownloadDaemon.py b/components/core/DownloadDaemon.py index 01da9379..f4976bdd 100644 --- a/components/core/DownloadDaemon.py +++ b/components/core/DownloadDaemon.py @@ -33,7 +33,6 @@ def __init__(self, ws): queue.Queue.__init__(self) self.ws = ws self.num_workers = 5 - self.start_workers() def add_to_queue(self, download): self.put(download) @@ -67,7 +66,7 @@ def worker(self): class MessageHandler(): - def __init__(self,ws): + def __init__(self, ws): self.num_workers = 5 self.ws = ws @@ -135,7 +134,7 @@ def worker(self): get_status(self.ws, None, data['params'][0]['gid']) db_lock.release() messageQueue.task_done() - + class RepeatedTimer(object): def __init__(self, interval, function, *args, **kwargs): self._timer = None @@ -240,8 +239,7 @@ def on_error(ws, error): def on_close(ws): - pass - + logging.info("Socket closed") def on_open(ws): initialize(ws) @@ -259,13 +257,13 @@ def starter(socket): on_close=on_close) ws.on_open = on_open handler = Handler(ws) + handlerLst.append(handler) # socketio.emit("test", {'data': 'A NEW FILE WAS POSTED'}, namespace='/news') threading.Thread(target=handler.start_workers).start() - mHandler = MessageHandler(ws) + mHandler = MessageHandler(ws) threading.Thread(target=mHandler.start_message_workers).start() messageQueue.join() ws.run_forever() -