[issue41539] print blocks with multiprocessing and buffered output

2021-06-26 Thread Martin
Martin added the comment: Thanks for the pointer, @pitrou! -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue41539] print blocks with multiprocessing and buffered output

2021-06-26 Thread Antoine Pitrou
Antoine Pitrou added the comment: This is just issue6721 again. The workaround is easy: just add `multiprocessing.set_start_method("forkserver")` at the start of your program. Also, this is more or less documented, though quite tersely: """Note that safely forking a multithreaded process is

[issue41539] print blocks with multiprocessing and buffered output

2021-06-26 Thread Martin
Martin added the comment: Yes, I think it should at least be documented. But then it practically says: "Do not use print in your library because it might be used in a threading context" This sounds unacceptable to me. It would be great to "just make it work". > I debugged it a bit and I

[issue41539] print blocks with multiprocessing and buffered output

2021-06-25 Thread Irit Katriel
Irit Katriel added the comment: Is there anything left here? I've seen it mentioned on other issues of this sort that mixing multiprocessing and threading leads to problems. Should we document that? -- ___ Python tracker

[issue41539] print blocks with multiprocessing and buffered output

2020-09-08 Thread Irit Katriel
Irit Katriel added the comment: This may be relevant: https://stackoverflow.com/questions/9337711/subprocess-popen-not-thread-safe It points to print() being not thread safe and suggests to use sys.stdout.write instead. That worked for me with your script. --

[issue41539] print blocks with multiprocessing and buffered output

2020-09-08 Thread Irit Katriel
Irit Katriel added the comment: You're right, this is a different issue. I debugged it a bit and I think the race may be between your print statement and the util._flush_std_streams() in Popen.__init__() of Lib/multiprocessing/popen_fork.py. --

[issue41539] print blocks with multiprocessing and buffered output

2020-08-14 Thread Ned Deily
Change by Ned Deily : -- nosy: +davin, pitrou ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue41539] print blocks with multiprocessing and buffered output

2020-08-13 Thread Martin
Martin added the comment: While I appreciate your suggestion, it does not help me much. The problem that people usually have is that the output is scrambled. That is not the problem I'm dealing with. I'm experiencing a deadlock caused by the print statement which seems like a python bug to

[issue41539] print blocks with multiprocessing and buffered output

2020-08-13 Thread Irit Katriel
Irit Katriel added the comment: Try putting a lock on the print statement. See this: https://stackoverflow.com/questions/40356200/python-printing-in-multiple-threads/ -- nosy: +iritkatriel ___ Python tracker

[issue41539] print blocks with multiprocessing and buffered output

2020-08-13 Thread Martin
Martin added the comment: python experiments/mp_problem.py also fails for: - 3.8.3, 3.8.2, 3.8.1, 3.8.0 - 3.7.7 - 3.6.10 -- ___ Python tracker ___

[issue41539] print blocks with multiprocessing and buffered output

2020-08-13 Thread Martin
New submission from Martin : I experience a problem with multiprocessing and print. I tried to make a minimal working example, please see the attached file. WITHOUT the offending print statement in the queue filler thread, everything works: - pytest experiments/mp_problem.py - pytest