This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Linux Query  RSS feed

 
Gracey Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I was wondering how i catch various signals in nix python so i can exit my programs gracefully? Please reply my post if you know the answer.

Thanks
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Python has something resembling the Java try/catch mechanism. There's a very good online guide to Python and a whole chapter on the topic.
 
Alisha Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gracey Smith wrote:Hello,
I was wondering how i catch various signals in nix python so i can exit my programs gracefully? Please reply my post if you know the answer.

Thanks


Simply "import signal", and see documentation of that module. But bear in mind that signals are weird with Python. The atomic unit of Python execution can span a C external function call, and that can take an indefinitely long time. So delivery of signals at the Python level can be delayed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!