Skip to content

Instantly share code, notes, and snippets.

@mkorpela
Created January 7, 2014 13:27
Show Gist options
  • Save mkorpela/8299257 to your computer and use it in GitHub Desktop.
Save mkorpela/8299257 to your computer and use it in GitHub Desktop.
Print stack trace during test execution. Works on POSIX not WINDOWS.
mport signal
import sys
import traceback
def debug(sig, frame):
""" This is a modified version of the one posted to http://stackoverflow.com/a/133384/308189
This one only writes the traceback to real stdout as robot framework redirects the stdout
"""
message = "\nSignal recieved : \nTraceback:\n"
message += ''.join(traceback.format_stack(frame))
sys.__stdout__.write(message+'\n')
signal.signal(signal.SIGUSR1, debug) # Register handler
# kill -30 pid TO GET IT TO WORK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment