Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1675 from reszelaz/issue1095
Browse files Browse the repository at this point in the history
fix: reduce memory leak of scans
  • Loading branch information
reszelaz authored Sep 1, 2021
2 parents 9f57f8a + f67eb74 commit 817b098
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/sardana/macroserver/msmacromanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

from taurus.core.util.log import Logger
from taurus.core.util.codecs import CodecFactory
from taurus.core.util.threadpool import ThreadPool

from sardana.sardanadefs import ElementType
from sardana.sardanamodulemanager import ModuleManager
Expand Down Expand Up @@ -1099,6 +1100,11 @@ def __init__(self, door):
name = "%s.%s" % (str(door), self.__class__.__name__)
self._macro_status_codec = CodecFactory().getCodec('json')
self.call__init__(Logger, name)
# ThreadPool to execute macros asynchronously
self._thread_pool = ThreadPool(Psize=1)

def add_job(self, job, callback=None, *args, **kw):
self._thread_pool.add(job, callback, *args, **kw)

def getDoor(self):
return self._door
Expand Down Expand Up @@ -1594,7 +1600,7 @@ def run(self, params, asynch=True):

if asynch:
# start the job of actually running the macro
self.macro_server.add_job(self.__runXML, self._jobEnded)
self.add_job(self.__runXML, self._jobEnded)
# return the proper xml
return self._xml
else:
Expand Down

0 comments on commit 817b098

Please sign in to comment.