cx_Oracle messes up signals

CRV§ADER//KY <[email protected]>
Newsgroups gmane.comp.python.db.cx-oracle
Message-ID <CAPRCXo19G78-02d4y8NR1Cp1sVf6cne2ccf8knrZ3FE8=J7eVg@mail.gmail.com>
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

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.