> On 30 Aug 2020, at 11:03, Stephane Tougard via Python-list > <python-list@python.org> wrote: > > On 2020-08-30, Chris Angelico <ros...@gmail.com> wrote: >>> I'm not even that makes sense, how 2 processes can share a thread ? >>> >> They can't. However, they can share a Thread object, which is the >> Python representation of a thread. That can lead to confusion, and >> possibly the OP's error (I don't know for sure, I'm just positing). > > A fork() is a copy of a process in a new process. If this process has a > thread (or several), they are part of the copy and the new process has > those threads as well.
No. See https://www.man7.org/linux/man-pages/man2/fork.2.html which says: “ Note the following further points: * The child process is created with a single thread—the one that called fork(). The entire virtual address space of the parent is replicated in the child, including the states of mutexes, condition variables, and other pthreads objects; the use of pthread_atfork(3) may be helpful for dealing with problems that this can cause.” Barry > > Unless there is a memory sharing between those processes, what happens > on one thread in the first process is totally independant of what > happens in the copy of this thread in the other process. > > I'm not specialist on multi-threading in Python, but it should not > change anything. Both processes (father and child) don't share the same > thread, each one has its own copy of the thread. > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list