[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multithread and locking issue

On 2020-05-14, MRAB <python at mrabarnett.plus.com> wrote:
> On 2020-05-14 23:36, Stephane Tougard wrote:
> Are there 100 threads running execute_sql? Do you put 100 "EXIT" 
> messages into the queue, one for each thread?

Nope, the EXIT comes from the main thread at the very end, once all
other threads are dead already and the programm is good to die. It's
just to ensure that the SQL thread dies as well.

> The "bare excepts" are a bad idea because they catch _all_ exceptions, 
> even the ones that might occur due to bugs, such as NameError 
> (misspelled variable or function).

At first, I did not use timeout nor try/except. The thing is that I
never catch any except anyway. The program just stuck. If I CTRL-C on
it, it shows a "acquire_lock()" status.

So I added the timeout to ensure that it does not stuck on the get/put
and the except to see if the problem comes from here. It does not come
from here. I can remove all that, the programm is still going to stuck
between 150/200 threads have been launched and have died.