From 827684ae3ee0202f70b62a692ae351c18def0fb9 Mon Sep 17 00:00:00 2001 From: Philip ABBET <philip.abbet@idiap.ch> Date: Thu, 13 Jul 2017 15:04:56 +0200 Subject: [PATCH] Fix: destroy the zmq contexts when not needed anymore Otherwise, they will be destroyed when Python decides to delete the objects, which might cause problems during the tests --- beat/core/agent.py | 5 +++++ beat/core/execution.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/beat/core/agent.py b/beat/core/agent.py index 076902b6..623f494b 100755 --- a/beat/core/agent.py +++ b/beat/core/agent.py @@ -74,6 +74,10 @@ class Server(MessageHandler): )) + def destroy(self): + self.context.destroy() + + def __str__(self): return 'Server(%s)' % self.address @@ -367,6 +371,7 @@ class Agent(object): self.db_process.rm() self.db_process = None + self.server.destroy() self.server = None return retval diff --git a/beat/core/execution.py b/beat/core/execution.py index 466d3090..555b0296 100755 --- a/beat/core/execution.py +++ b/beat/core/execution.py @@ -152,6 +152,7 @@ class Executor(object): self.output_list = None self.data_sinks = [] self.data_sources = [] + self.context = None # runs validation if required self.errors = [] @@ -183,6 +184,7 @@ class Executor(object): self.output_list = None self.data_sinks = [] self.data_sources = [] + self.context = None self.db_address = None if not isinstance(data, dict): #user has passed a file pointer @@ -268,6 +270,10 @@ class Executor(object): self.data_sources = [] self.agent = None + if self.context is not None: + self.context.destroy() + self.context = None + def _prepare_inputs(self): """Prepares all input required by the execution.""" -- GitLab