Skip to content

Instantly share code, notes, and snippets.

@pstiasny
Last active August 29, 2015 14:02
Show Gist options
  • Save pstiasny/7e0f6cc46a1a092037d2 to your computer and use it in GitHub Desktop.
Save pstiasny/7e0f6cc46a1a092037d2 to your computer and use it in GitHub Desktop.
record reaching points in code
import os
import inspect
def record_point(name=''):
pid = os.getpid()
f = inspect.currentframe()
# redis.set ...
print('{} = {}:{}:{}'.format(
pid,
f.f_back.f_code.co_filename,
f.f_back.f_lineno,
name))
record_point()
record_point('hehe')
import sys
import signal
import traceback
def report(signum, frame):
logfile = sys.stdout # open(...)
traceback.print_stack(file=logfile)
print >>logfile, '***'
signal.signal(signal.SIGUSR1, report)
def stuff():
while True: pass
stuff()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment