[cx-oracle-users] cx_Oracle messes up signals
Brought to you by:
atuining
|
From: CRV§ADER//KY <cru...@gm...> - 2014-08-06 11:35:24
|
Hi all,
I'm using cx_Oracle 5.1.2 on Python 2.6 on Linux.
I found out that cx_Oracles interferes heavily with signal handling.
This is BAD, because it causes mysterious failures later on in the
code. It personally took me A LOT of time to figure what the heck was
going on.
Expected behaviour would be for cx_Oracle to respect whatever signal
handling is used in the code invoking the library. If you _really_
need to touch signals, that should be done in a subprocess.
Thanks
proof-of-concept code:
#!/usr/bin/env python
import cx_Oracle
import subprocess
import signal
import time
import os
from threading import Thread
def signalme():
time.sleep(2)
os.kill(os.getpid(), signal.SIGWINCH)
# Completely ignore SIGWINCH
signal.signal(signal.SIGWINCH, signal.SIG_IGN)
signal.siginterrupt(signal.
SIGWINCH, False)
print "do a syscall"
Thread(target=signalme).start()
subprocess.check_call("sleep 5", shell=True)
print "run oracle"
connection = cx_Oracle.connect('myuser', 'mypass', 'mytns')
connection.close()
print "do a syscall"
Thread(target=signalme).start()
subprocess.check_call("sleep 5", shell=True)
print "all done!"
Output:
do a syscall
run oracle
do a syscall
Traceback (most recent call last):
File "./oracle_test.py", line 30, in <module>
subprocess.check_call("sleep 5", shell=True)
File "/algo/algos2dev4/AlgoOne-EC/third-party-apps/python/lib/python2.6/subprocess.py",
line 457, in check_call
retcode = call(*popenargs, **kwargs)
File "/algo/algos2dev4/AlgoOne-EC/third-party-apps/python/lib/python2.6/subprocess.py",
line 444, in call
return Popen(*popenargs, **kwargs).wait()
File "/algo/algos2dev4/AlgoOne-EC/third-party-apps/python/lib/python2.6/subprocess.py",
line 1123, in wait
pid, sts = os.waitpid(self.pid, 0)
OSError: [Errno 4] Interrupted system call
|