Skip to content

Instantly share code, notes, and snippets.

@shreyansb
Created May 6, 2012 22:40
Show Gist options
  • Select an option

  • Save shreyansb/2624848 to your computer and use it in GitHub Desktop.

Select an option

Save shreyansb/2624848 to your computer and use it in GitHub Desktop.
TIL: python signal, setproctitle, custom exceptions
### 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