SUMMARY: Our python program, which is multithreaded, hung at a futex()
call. Is this due to PyGreSQL being not thread safe? Or some other issue?
Hi. Python 2.5.4 on CentOS 5.6 (64-bit) using PyGreSQL 4.0
Our Python program talks to PostgreSQL database using PyGreSQL.
Now it is hung, and strace shows it is waiting for futex:
futex(0x1e24cfc0, FUTEX_WAIT_PRIVATE, 0, NULL
I grabbed a core using "gcore", and apparently it is in sem_wait() :
(gdb) bt
#0 0x0000003583a0cd01 in sem_wait () from /lib64/libpthread.so.0
#1 0x00002ab1fcc9674d in PyThread_acquire_lock (lock=0x1e24cfc0,
waitflag=1) at Python/thread_pthread.h:349
#2 0x00002ab1fcc9a2e2 in lock_PyThread_acquire_lock
(self=0x2ab1fcf7a108, args=<value optimized out>) at
./Modules/threadmodule.c:46
#3 0x00002ab1fcc6ba8e in call_function (f=0x1e3e13f0,
throwflag=<value optimized out>) at Python/ceval.c:3612
#4 PyEval_EvalFrameEx (f=0x1e3e13f0, throwflag=<value optimized out>)
at Python/ceval.c:2304
Is there anything we should add to our code to make it more robust
so that it doesn't hang?
I see at http://www.pygresql.org/readme.html:
PyGreSQL is not thread-safe on the connection level. Therefore
we recommend using DBUtils <http://www.webwareforpython.org/DBUtils>
for multi-threaded environments, which supports both PyGreSQL interfaces
Is this kind of futex hang what happens due to PyGreSQL being not thread safe?
Is there any way to extract the Python stack trace from the core file?
Our python program does have multiple threads, but each thread is supposed
to set up its own connection to Postgres.
Can we fix our code to make it safe or do we need to move to DBUtils or another
python postgresql client that does claim to be thead safe?
Thanks,
Aleksey
Sys Admin
_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql