From 7f8dd84f91ad8aa9a16aa5a245c85e1b031ba167 Mon Sep 17 00:00:00 2001
From: Thomas Kluyver <thomas@kluyver.me.uk>
Date: Tue, 9 Mar 2021 12:19:15 +0000
Subject: [PATCH] Get rid of ainit workaround

---
 webservice/webservice.py | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/webservice/webservice.py b/webservice/webservice.py
index 5770aba73..930979431 100644
--- a/webservice/webservice.py
+++ b/webservice/webservice.py
@@ -626,11 +626,13 @@ async def update_mdc_status(mdc: MetadataClient, action: str,
 
 
 class ActionsServer:
-    def __init__(self, config, mode, job_db, mdc):
+    def __init__(self, config, mode):
         self.config = config
         self.mode = mode
-        self.job_db = job_db
-        self.mdc = mdc
+
+        init_config_repo(config['config-repo'])
+        self.job_db = init_job_db(config)
+        self.mdc = init_md_client(config)
 
         # Set up a ZMQ socket to listen for requests
         self.zmq_ctx = zmq.asyncio.Context()
@@ -644,17 +646,9 @@ class ActionsServer:
         self.socket.bind("{}:{}".format(config['web-service']['bind-to'],
                                         config['web-service']['port']))
 
-    # __init__ can't be async - this is a workaround
-    @classmethod
-    async def ainit(cls, config, mode):
-        init_config_repo(config['config-repo'])
-        job_db = init_job_db(config)
-        mdc = init_md_client(config)
-        return cls(config, mode, job_db, mdc)
-
     @classmethod
     async def launch(cls, config, mode):
-        server = await cls.ainit(config, mode)
+        server = cls(config, mode)
         return await server.run()
 
     async def run(self):
-- 
GitLab