Re: Multithread and locking issue

2020-05-15 Thread Chris Angelico
On Fri, May 15, 2020 at 6:25 PM Cameron Simpson wrote: > > On 15May2020 05:57, Stephane Tougard wrote: > >On 2020-05-15, Chris Angelico wrote: > >> Seconded. If you know how many threads you're going to have, just > >> open > >> that many connections. If not, there's a connection-pooling feature

Re: Multithread and locking issue

2020-05-15 Thread Cameron Simpson
On 15May2020 05:57, Stephane Tougard wrote: On 2020-05-15, Chris Angelico wrote: Seconded. If you know how many threads you're going to have, just open that many connections. If not, there's a connection-pooling feature as part of psycopg2 (if I'm not mistaken). This would be far far easier t

Re: Multithread and locking issue

2020-05-15 Thread Antoon Pardon
Op 15/05/20 om 00:36 schreef Stephane Tougard: Hello, A multithreaded software written in Python is connected with a Postgres database. To avoid concurrent access issue with the database, it starts a thread who receive all SQL request via queue.put and queue.get (it makes only insert, so no

Re: Multithread and locking issue

2020-05-14 Thread Stephane Tougard
On 2020-05-15, Chris Angelico wrote: > Seconded. If you know how many threads you're going to have, just open > that many connections. If not, there's a connection-pooling feature as > part of psycopg2 (if I'm not mistaken). This would be far far easier > to work with than a fragile queueing setu

Re: Multithread and locking issue

2020-05-14 Thread Chris Angelico
On Fri, May 15, 2020 at 9:20 AM Cameron Simpson wrote: > > On 14May2020 22:36, Stephane Tougard wrote: > >A multithreaded software written in Python is connected with a Postgres > >database. To avoid concurrent access issue with the database, it starts > >a thread who receive all SQL request via

Re: Multithread and locking issue

2020-05-14 Thread Stephane Tougard
On 2020-05-14, MRAB 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

Re: Multithread and locking issue

2020-05-14 Thread MRAB
On 2020-05-14 23:36, Stephane Tougard wrote: Hello, A multithreaded software written in Python is connected with a Postgres database. To avoid concurrent access issue with the database, it starts a thread who receive all SQL request via queue.put and queue.get (it makes only insert, so no issu

Re: Multithread and locking issue

2020-05-14 Thread Cameron Simpson
On 14May2020 22:36, Stephane Tougard wrote: A multithreaded software written in Python is connected with a Postgres database. To avoid concurrent access issue with the database, it starts a thread who receive all SQL request via queue.put and queue.get (it makes only insert, so no issue with the

Multithread and locking issue

2020-05-14 Thread Stephane Tougard
Hello, A multithreaded software written in Python is connected with a Postgres database. To avoid concurrent access issue with the database, it starts a thread who receive all SQL request via queue.put and queue.get (it makes only insert, so no issue with the return of the SQL request). As lon