Ma77Ball commented on code in PR #5046:
URL: https://github.com/apache/texera/pull/5046#discussion_r3232754727


##########
amber/src/main/python/core/architecture/managers/executor_manager.py:
##########
@@ -114,10 +114,24 @@ def load_executor_definition(self, code: str) -> 
type(Operator):
     def close(self) -> None:
         """
         Close the tmp fs and release all resources created within it.
+        This also evicts the loaded operator module from ``sys.modules``
+        and removes the tmp fs path from ``sys.path`` so a single call
+        fully reverses every global side-effect performed by ``fs`` and
+        ``load_executor_definition``.
         :return:
         """
+        if "fs" not in self.__dict__:
+            # fs was never materialized; nothing to clean up.
+            return
+        root = self.fs.getsyspath("/")
         self.fs.close()
-        logger.debug(f"Tmp directory {self.fs.getsyspath('/')} is closed and 
cleared.")
+        try:
+            sys.path.remove(str(Path(root)))
+        except ValueError:
+            pass

Review Comment:
   I could subclass TempFS so it tracks the sys.path / sys.modules entries 
itself, letting close() collapse to just self.fs.close(). Want me to refactor 
it that way?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to