1

I have a script that loops infinitely and makes an Oracle call through cx_oracle every X seconds. I also have a signal handler which should allow the script to exit gracefully after it finishes running the oracle procedure. The problem I am running into is the oracle call appears to be interupted by a sigint or a sigterm even though I am handling these.

It is throwing the following error: ORA-01013: user requested cancel of current operation

Here is a sample code (trimmed):

def signal_handler(signum, frame):
        print time.strftime(settings.FDATE) + " - Quitting safely..."
        global exit
        try:
                exit = 1
        except KeyboardInterrupt:
                exit = 1
                print 'Script is quitting safely, please wait...'

signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)

while not exit:
    #database call here
    sleep 5 #actually taking this value from a settings file

I'm not sure if it makes a difference but I am also multithreading based on the results of the database call but the error still happens within the main while loop.

Mocking
  • 1,764
  • 2
  • 20
  • 36

1 Answers1

1

You are right that Oracle does use SININT to cancel the current operation. To avoid conflict you may want to consider using other signals such as SIGQUIT or SIGSTOP.

nwoo
  • 11
  • 1