Re: Does plpython support threading?

Поиск
Список
Период
Сортировка
От Jinhua Luo
Тема Re: Does plpython support threading?
Дата
Msg-id CAAc9rOw7d3j_YLq85EZ4zj1=KWPts5mjuzWnhf6Hy4EJNC8Zaw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Does plpython support threading?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
The new thread do not call any pg API or access any pg specific data.
The pg backend (main thread) puts string message into the python
Queue, and the new thread gets from the Queue and write to file, it's
simple and clear logic.

I test the same codes standalone, it works, but when I move them into
the plpython function. The new thread would be pause and seems freeze
(as said above, I even try to put a dead loop in the thread, it
doesn't run a dead loop actually).

So I guess it's somehow plpython specific limit?

Regards,
Jinhua Luo


2016-02-08 0:45 GMT+08:00 Tom Lane <tgl@sss.pgh.pa.us>:
> 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 по дате отправления:

Предыдущее
От: Fujii Masao
Дата:
Сообщение: Re: GIN pending list clean up exposure to SQL
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: WAL Re-Writes