Re: Does plpython support threading?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jinhua Luo <luajit(dot)io(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Does plpython support threading?
Date: 2016-02-07 16:45:26
Message-ID: 27172.1454863526@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jinhua Luo <luajit(dot)io(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-02-07 16:52:09 Re: Way to check whether a particular block is on the shared_buffer?
Previous Message Noah Misch 2016-02-07 16:34:17 Re: pgcommitfest reply having corrupted subject line