Install gdb and Python debugging extensions
$ sudo apt-get install gdb python2.7-dbg
If the process is already running, you can attach to it provided you know the process ID.
$ gdb python [process id]
Attaching to a running process like this will cause it to stop. You can tell it to continue running with c command.
If the hang occurs in some thread, the following commands may be handy:
(gdb) info threads
Current thread is marked with *. To see where it is in Python code, use py-list: