[issue35902] Forking from background thread

2019-02-06 Thread Antoine Pitrou
Antoine Pitrou added the comment: By the way, one likely explanation why this happens only when fork() is called from a non-main thread is that the non-main thread (which becomes the main thread in the child process) ends with pthread_exit() while the main thread would end with exit().

[issue35902] Forking from background thread

2019-02-06 Thread Antoine Pitrou
Antoine Pitrou added the comment: It is actually quite an intricate problem. What happens is that child process *main thread* ends, but not its background sleeping thread (the `lambda: time.sleep(3600)`). To diagnose it, you can display the process tree: ``` $ ps fu USER PID %CPU

[issue35902] Forking from background thread

2019-02-06 Thread Antoine Pitrou
Change by Antoine Pitrou : -- nosy: +pablogsal ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35902] Forking from background thread

2019-02-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: Unless it's clear that there is a buggy behavior or a useful feature request, it would be better to move this to StackOverflow which is a more appropriate forum for general questions on how Python works internally. -- nosy: +rhettinger

[issue35902] Forking from background thread

2019-02-05 Thread Vadim Tsozik
Vadim Tsozik added the comment: Thank you for your reply. I understand that forking and threads do not mix well if developer is not careful and child doesn't clear/reset synchronization variables inherited from parent. However this is not the case in provided code sample. The answer to my

[issue35902] Forking from background thread

2019-02-05 Thread Christian Heimes
Christian Heimes added the comment: In general threads and forks don't mix well. If you fork from any thread but the main thread, you can run into undefined behavior. Daemon threads are a special property of Python's threading model. You need to have one non-daemon thread running to keep

[issue35902] Forking from background thread

2019-02-05 Thread Vadim Tsozik
New submission from Vadim Tsozik : Attached is code sample that forks child process either from main or from background thread. Child starts and joins all of its threads except a sleeping daemon. If parent forks child from main thread program exits immediately after child threads are joined