Re: Does plpython support threading? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Does plpython support threading?
Date
Msg-id 27172.1454863526@sss.pgh.pa.us
Whole thread Raw
In response to Does plpython support threading?  (Jinhua Luo <luajit.io@gmail.com>)
Responses Re: Does plpython support threading?
List pgsql-hackers
Jinhua Luo <luajit.io@gmail.com> writes:
> In my plpython function, I create new thread to do some routine works.
> But I found the thread doesn't work, it would run a while, but
> suddenly pause and stop working. For example, I write a test dead loop
> to print something to file, but it would stop printing after some
> time.

> I am wondering whether plpython supports threading or not.

Creating multiple threads inside a Postgres backend is playing with fire.
You can make it work if you're very very careful, but what's more likely
to happen is you get burned.  None of the backend code is multithread
safe, so you must absolutely ensure that control never gets out of
libpython except in the main thread.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: pgcommitfest reply having corrupted subject line
Next
From: Robert Haas
Date:
Subject: Re: Way to check whether a particular block is on the shared_buffer?