source: trunk/python/Rappture/signalHandler.py @ 829

Last change on this file since 829 was 497, checked in by dkearney, 18 years ago

added checks to configure.in to find where python and perl live,
added .in files for python and perl build files
configure now builds perl/Makefile.PL and python/setup.py and fits
it with the correct values needed to build and install the module
in the correct directory, where it will live in the rappture distribution.
there had been talk of using env variables to point python and perl
to where these modules live, so that is the current line of thinking.
added queue module for python. the Rappture.queue module's purpose
is to make it easy to send a job to the pbs and condor queues and
track the job using rappture. pbs is kinda complete, condor is not
complete and is still being worked on. the signalHandler and tools
python modules came from left over code that all python rappture
applications might want to include to make the developers life
a little more enjoyable.

File size: 2.3 KB
Line 
1# ----------------------------------------------------------------------
2#
3# ======================================================================
4#  AUTHOR:  Derrick Kearney, Purdue University
5#  Copyright (c) 2005  Purdue Research Foundation, West Lafayette, IN
6# ======================================================================
7
8import sys
9import signal
10
11qID = []
12queue_type = ''
13
14def sigGEN_handler(signal, frame):
15    global qID
16    global queue_type
17    if qID :
18        for id in xrange(len(qID)):
19            sys.stdout.write("Killing job with qID = :%s:\n" % (qID[id]))
20            sys.stdout.flush()
21            if queue_type == 'PBS':
22                rmCmdOut = getCommandOutput('qdel %s' % (qID[id]))
23            elif queue_type == 'Condor':
24                rmCmdOut = getCommandOutput('condor_rm %s' % (qID[id]))
25            else:
26                # unrecognized queue_type
27                break
28            sys.stdout.write("\n%s\n" % rmCmdOut)
29            sys.stdout.flush()
30            time.sleep(10)
31    sys.stdout.write("\nEXITING...\n")
32    sys.stdout.flush()
33    sys.exit(-1)
34
35
36def sigINT_handler(signal, frame):
37    sys.stdout.write('Received SIGINT!\n')
38    sys.stdout.flush()
39    sigGEN_handler(signal, frame)
40
41def sigHUP_handler(signal, frame):
42    sys.stdout.write('Received SIGHUP!\n')
43    sys.stdout.flush()
44    sigGEN_handler(signal, frame)
45
46def sigQUIT_handler(signal, frame):
47    sys.stdout.write('Received SIGQUIT!\n')
48    sys.stdout.flush()
49    sigGEN_handler(signal, frame)
50
51def sigABRT_handler(signal, frame):
52    sys.stdout.write('Received SIGABRT!\n')
53    sys.stdout.flush()
54    sigGEN_handler(signal, frame)
55
56def sigTERM_handler(signal, frame):
57    sys.stdout.write('Received SIGTERM!\n')
58    sys.stdout.flush()
59    sigGEN_handler(signal, frame)
60
61def sigSTOP_handler(signal, frame):
62    sys.stdout.write('Received SIGSTOP!\n')
63    sys.stdout.flush()
64    sigGEN_handler(signal, frame)
65
66def sigKILL_handler(signal, frame):
67    sys.stdout.write('Received SIGKILL!\n')
68    sys.stdout.flush()
69    sigGEN_handler(signal, frame)
70
71signal.signal(signal.SIGINT, sigINT_handler)
72signal.signal(signal.SIGHUP, sigHUP_handler)
73signal.signal(signal.SIGQUIT, sigQUIT_handler)
74signal.signal(signal.SIGABRT, sigABRT_handler)
75signal.signal(signal.SIGTERM, sigTERM_handler)
76#signal.signal(signal.SIGSTOP, sigSTOP_handler)
77#signal.signal(signal.SIGKILL, sigKILL_handler)
78
Note: See TracBrowser for help on using the repository browser.