Multithread and locking issue

Chris Angelico rosuav at gmail.com
Fri May 15 04:31:11 EDT 2020


On Fri, May 15, 2020 at 6:25 PM Cameron Simpson <cs at cskk.id.au> wrote:
>
> On 15May2020 05:57, Stephane Tougard <stephane at sdf.org> wrote:
> >On 2020-05-15, Chris Angelico <rosuav at gmail.com> 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 setup.
> >
> >I've done like that (more or less), it works fine.
> >
> >I note that que queuing module or Python is "fragile".
>
> It isn't fragile, it is very robust. Chris' statement (to my mind) means
> either that it is an additional layer of complexity to your programme
> (which you need to debug) or the pervasive fear of threaded programming,
> which has its pitfalls but is very rewarding and not hard to do safely
> and easily unless you do something agressive and complex.
>

Correct. The complexity caused by not simply embracing threaded
programming is what's fragile.

ChrisA


More information about the Python-list mailing list