diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-12-02 11:01:03 +0000 |
---|---|---|
committer | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-12-02 11:01:03 +0000 |
commit | 06d0e78abecfd25ec0b746227a65bea8dac46cf5 (patch) | |
tree | bb8d236fedf139b85e3828aed0e2b26c32b39b6e | |
parent | 3d0dcabec14ec5a1f9364ddd58d91de800eb8a02 (diff) | |
download | import-06d0e78abecfd25ec0b746227a65bea8dac46cf5.tar.gz |
getting interrupt
-rwxr-xr-x | exts/pip.find_deps | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/exts/pip.find_deps b/exts/pip.find_deps index cae8003..9019343 100755 --- a/exts/pip.find_deps +++ b/exts/pip.find_deps @@ -254,17 +254,6 @@ def find_runtime_deps(source, name, version=None): stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE) - def handler(signal, frame): - logging.debug('sigterm!') - logging.debug('terminate!') - p.terminate() - logging.debug('waiting...') - p.wait() - logging.debug('child terminated') - error('got sigterm!') - - signal.signal(signal.SIGTERM, handler) - # We close stdin on parent side to prevent the child from blocking # if it reads on stdin p.stdin.close() @@ -302,7 +291,27 @@ def find_runtime_deps(source, name, version=None): return runtime_deps +import time + +def handler(): + with open('/tmp/handler.txt', 'w'): + f.write('hello there\n') + def main(): + + signal.signal(signal.SIGTERM, handler) + + try: + i = 0 + while True: + i += 1 + logging.debug(i) + time.sleep(1) + except: + with open('/tmp/interrupt.txt', 'w') as f: + f.write('hello there\n') + raise + if len(sys.argv) not in [3, 4]: print('usage: %s PACKAGE_SOURCE_DIR NAME [VERSION]' % sys.argv[0]) sys.exit(1) @@ -317,4 +326,5 @@ def main(): print(json.dumps(root)) if __name__ == '__main__': + print('hello') PythonExtension().run() |