gaogaotiantian commented on code in PR #54580:
URL: https://github.com/apache/spark/pull/54580#discussion_r2875337554


##########
python/pyspark/logger/worker_io.py:
##########
@@ -223,7 +223,11 @@ def context_provider() -> dict[str, str]:
             - class_name: Name of the class that initiated the logging if 
available
     """
 
-    def is_pyspark_module(module_name: str) -> bool:
+    def is_pyspark_module(frame: FrameType) -> bool:
+        module_name = frame.f_globals.get("__name__", "")
+        if module_name == "__main__":
+            if mod := sys.modules.get("__main__", None):
+                module_name = mod.__spec__.name

Review Comment:
   This is needed for the test. The original code did not consider the simple 
worker case, where the worker module is executed with `python -m XXX` - the 
`__name__` would be `__main__` and our method to check if it's pyspark module 
will give a wrong result.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to