> On 29 Aug 2020, at 18:01, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
>
> On Sat, 29 Aug 2020 18:24:10 +1000, John O'Hagan <resea...@johnohagan.com>
> declaimed the following:
>
>> There's no error without the sleep(1), nor if the Process is started
>> before the Thread, nor if two Processes are used instead, nor if two
>> Threads are used instead. IOW the error only occurs if a Thread is
>> started first, and a Process is started a little later.
>>
>> Any ideas what might be causing the error?
>>
>
> Under Linux, multiprocessing creates processes using fork(). That means
> that, for some fraction of time, you have TWO processes sharing the same
> thread and all that entails (if it doesn't overlay the forked process with
> a new executable, they are sharing the thread until the thread exits).
In the parent you have 1 or more threads.
After fork the new process has 1 thread, which is not shared with the parent.
Any extra threads are not in the new process. But the memory in the new
process will have data structures from the parents other threads.
So no you never have two processes sharing an threads.
This leads to problems with locks.
Barry
>
> https://stackoverflow.com/questions/54466572/how-to-properly-multithread-in-opencv-in-2019
> (which points to)
> https://answers.opencv.org/question/32415/thread-safe/?answer=32452#post-id-32452
> """
> The library itself is thread safe in that you can have multiple calls into
> the library at the same time, however the data is not always thread safe.
> """
>
> The sleep(1), when compounded with the overhead of starting the thread,
> and then starting the process, likely means the thread had exited before
> the process actually is started. Try replacing the sleep(2) in the work
> code with something like sleep(30) -- I hypothesize that you'll get the
> same error condition even with the sleep(1) in place.
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list