K_Anudeep
Databricks Employee
Databricks Employee

@ToBeDataDriven ,
redirect_stdout is process-global, not per-thread.
It temporarily rebinds sys.stdout for the whole interpreter, so in a thread pool, you can accidentally swallow other threads’ prints while the with block is active. It’s not thread-safe for your use case. If you need all the output except fs.put, then you need to isolate it; otherwise, I dont think there is another option.

 

Anudeep

View solution in original post