(self)
Close the context and clean up.
        Should only be called once.
Close the context and clean up.
        Should only be called once.
Close the context and clean up . Should only be called once .
def close(self) -> None:
        """Close the context and clean up.
        Should only be called once."""
        if not self.has_closed:
            # update the run.txt with stopping time
            self.run_txt_data["stop_time"] = datetime.datetime.now().isoformat(sep=" ")
            with open(os.path.join(self.submit_config.run_dir, "run.txt"), "w") as f:
                pprint.pprint(self.run_txt_data, stream=f, indent=4, width=200, compact=False)
            self.has_closed = True

            # detach the global singleton
            global _run_context
            if _run_context is self:
                _run_context = None
def close ( self ) -> None : if not self . has_closed : # update the run.txt with stopping time self . run_txt_data [ "stop_time" ] = datetime . datetime . now ( ) . isoformat ( sep = " " ) with open ( os . path . join ( self . submit_config . run_dir , "run.txt" ) , "w" ) as f : pprint . pprint ( self . run_txt_data , stream = f , indent = 4 , width = 200 , compact = False ) self . has_closed = True # detach the global singleton global _run_context if _run_context is self : _run_context = None