Created
May 6, 2012 22:40
-
-
Save shreyansb/2624848 to your computer and use it in GitHub Desktop.
TIL: python signal, setproctitle, custom exceptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### signals | |
| # http://docs.python.org/library/signal.html | |
| # example: https://github.com/binarydud/pyres/blob/master/pyres/scheduler.py | |
| import signal | |
| signal.signal(signal.SIGTERM, self.schedule_shutdown) | |
| def schedule_shutdown(): | |
| self._shutdown = True | |
| ### setproctitle | |
| # http://pypi.python.org/pypi/setproctitle/ | |
| import setproctitle | |
| setproctitle.setproctitle('python: migrating photos from appengine') | |
| # $ ps -e -o pid,command | grep [p]ython | |
| # 4858 (python) | |
| # 5367 python: migrating photos from appengine | |
| ### custom exceptions | |
| # https://gist.github.com/2624788 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment