andyrimmer / Platypus

Platypus Variant Caller
GNU General Public License v3.0
105 stars 38 forks source link

Fixes Platypus such that it can be interrupted with ctrl-c #40

Closed jrandall closed 9 years ago

jrandall commented 9 years ago

While performing variant calling, Platypus ignores all KeyboardInterrupts (cython prints Exception KeyboardInterrupt: ... ignored messages). This is because runner transfers control of the main thread to the variant calling cython code, which does not run PyErr_CheckSignals().

Rather than adding signal handling to the cython side of things, I've addressed this in this PR by keeping the main thread python interpreter alive (sleeping for 1 second at a time until all subprocesses are done) and handling any KeyboardExceptions that interrupt that sleep.

In order to make this work for nCPU=1, I've needed to eliminate the special case for that such that a separate processing thread is spawned for the variant caller when nCPU=1 (so technically this means that even with nCPU=1, Platypus would have two processes but one of them would only be performing a few of operations per second). If that is not acceptable, then it might be possible to add another special case to the single process cython such that it implements the signal handlers.

andyrimmer commented 9 years ago

Hi Josh,

Thanks for this. I'm not working on the Platypus code right now, so I'm forwarding this to Dan at WTCHG.

Kind regards, Andy

On Wed, Jun 24, 2015 at 5:32 PM, Joshua C. Randall <notifications@github.com

wrote:

While performing variant calling, Platypus ignores all KeyboardInterrupts (cython prints Exception KeyboardInterrupt: ... ignored messages). This is because runner transfers control of the main thread to the variant calling cython code, which does not run PyErr_CheckSignals().

Rather than adding signal handling to the cython side of things, I've addressed this in this PR by keeping the main thread python interpreter alive (sleeping for 1 second at a time until all subprocesses are done) and handling any KeyboardExceptions that interrupt that sleep.

In order to make this work for nCPU=1, I've needed to eliminate the special case for that such that a separate processing thread is spawned for the variant caller when nCPU=1 (so technically this means that even with nCPU=1, Platypus would have two processes but one of them would only be performing a few of operations per second). If that is not acceptable, then it might be possible to add another special case to the single process

cython such that it implements the signal handlers.

You can view, comment on, or merge this pull request online at:

https://github.com/andyrimmer/Platypus/pull/40 Commit Summary

  • Changes all bare except: statements to except Exception:
  • Fixes Platypus so that it can be killed by a KeyboardInterrupt

File Changes

Patch Links:

— Reply to this email directly or view it on GitHub https://github.com/andyrimmer/Platypus/pull/40.

This email is sent on behalf of Genomics plc, a public limited company registered in England and Wales with registered number 8839972, VAT registered number 189 2635 65 and registered office at 24 Cornhill, London, EC3V 3ND, United Kingdom. The contents of this e-mail and any attachments are confidential to the intended recipient. If you are not the intended recipient please do not use or publish its contents, contact Genomics plc immediately at info@genomicsplc.com info@genomicsltd.com then delete. You may not copy, forward, use or disclose the contents of this email to anybody else if you are not the intended recipient. Emails are not secure and may contain viruses.

?

dancooke commented 9 years ago

Thanks Josh. Merged. I'll try to get this into the release version asap.

Best Dan