From 9f6418bf60142a3d0cfc427cea8d59793793f9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Tue, 29 May 2018 16:09:41 +0200 Subject: [PATCH] Support creating thread-local xmlrpc clients in SupervisorBaseMixin --- lib/tfw/mixins/supervisor_mixin.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/tfw/mixins/supervisor_mixin.py b/lib/tfw/mixins/supervisor_mixin.py index f9bbd6b..cbd6fcd 100644 --- a/lib/tfw/mixins/supervisor_mixin.py +++ b/lib/tfw/mixins/supervisor_mixin.py @@ -9,8 +9,18 @@ from os import remove from tfw.config import TFWENV +def get_supervisor_instance(): + return xmlrpc.client.ServerProxy(TFWENV.SUPERVISOR_HTTP_URI).supervisor + + class SupervisorBaseMixin: - supervisor = xmlrpc.client.ServerProxy(TFWENV.SUPERVISOR_HTTP_URI).supervisor + supervisor = get_supervisor_instance() + + def threadlocalise_supervisor_instance(self): + """ + Give this instance non-static, thread local xmlrpc client + """ + self.supervisor = get_supervisor_instance() class SupervisorMixin(SupervisorBaseMixin):