Graceful exit in Jython

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jlm699
    Contributor
    • Jul 2007
    • 314

    Graceful exit in Jython

    Greetings fellow developers.

    I have a 'super loop' in jython (ie, while True: ) that does not take input from the user at any point. It simply runs as a psuedo-daemon in the background. I was figuring out how to play around with the signal module in python to have a way to gracefully exit the application (without having to close the command prompt that it's running in). When I exit the application I would like to print a line to my log file that simply gives the time and says, exiting application, among cleaning up certain things.

    Jython doesn't allow you to use the signal module... :( I'm not quite sure where to go with this one. Does anybody have any ideas about how to exit out of a super loop in Jython, or perhaps a module that will allow me to intercept a CTRL-C or similar keystroke?!?

    Thanks in advance to anyone that can help
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    If you could use CPython, that would allow you to use signals, since the underlying C can use them.

    Comment

    • jlm699
      Contributor
      • Jul 2007
      • 314

      #3
      Originally posted by Laharl
      If you could use CPython, that would allow you to use signals, since the underlying C can use them.
      I'm sorry I'm not familiar with CPython.. I need to interact with a jar file... so it would seem that Jython is necessary unless CPython has some type of Java accesability

      Comment

      Working...