This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch aevri/casdprocessmanager2 in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit bd984334f2d5590fd60d16f775a2132dabac2831 Author: Angelos Evripiotis <[email protected]> AuthorDate: Fri Oct 11 13:32:21 2019 +0100 CASDProcessManager: 'release_resources' convention Elsewhere in cascache, cleaning up is called 'release_resources', so follow that convention for consistency. Also fix a case where self._process was not set to None in terminate(). --- src/buildstream/_cas/cascache.py | 3 +-- src/buildstream/_cas/casdprocessmanager.py | 25 +++++++++++-------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py index 091b14e..aefc1b9 100644 --- a/src/buildstream/_cas/cascache.py +++ b/src/buildstream/_cas/cascache.py @@ -184,8 +184,7 @@ class CASCache(): if self._casd_process_manager: self.close_grpc_channels() - self._casd_process_manager.terminate(messenger) - self._casd_process_manager.clean_up() + self._casd_process_manager.release_resources(messenger) self._casd_process_manager = None # contains(): diff --git a/src/buildstream/_cas/casdprocessmanager.py b/src/buildstream/_cas/casdprocessmanager.py index 697b21f..3a434ad 100644 --- a/src/buildstream/_cas/casdprocessmanager.py +++ b/src/buildstream/_cas/casdprocessmanager.py @@ -100,14 +100,20 @@ class CASDProcessManager: return os.path.join(self._log_dir, str(self.start_time) + ".log") - # terminate() + # release_resources() # - # Terminate the buildbox casd process + # Terminate the process and release related resources. # - # Args: - # messenger (buildstream._messenger.Messenger): Messenger to forward information to the frontend + def release_resources(self, messenger=None): + self._terminate(messenger) + self._process = None + shutil.rmtree(self._socket_tempdir) + + # _terminate() + # + # Terminate the buildbox casd process. # - def terminate(self, messenger=None): + def _terminate(self, messenger=None): assert self._watcher is None assert self._failure_callback is None @@ -115,7 +121,6 @@ class CASDProcessManager: if return_code is not None: # buildbox-casd is already dead - self._process = None if messenger: messenger.message( @@ -149,7 +154,6 @@ class CASDProcessManager: messenger.message( Message(MessageType.WARN, "Buildbox-casd didn't exit in time and has been killed") ) - self._process = None return if return_code != 0 and messenger: @@ -162,13 +166,6 @@ class CASDProcessManager: ) ) - # clean_up() - # - # After termination, clean up any additional resources - # - def clean_up(self): - shutil.rmtree(self._socket_tempdir) - # set_failure_callback() # # Call this function if the CASD process stops unexpectedly.
