1

I have a multi-threaded Bottle/Python web application that only occasionally hangs. The source can be downloaded here: https://github.com/whbrewer/spc

I've been trying to figure out what is causing the hang, but since it only happens very occasionally and I have not yet figured out how to reproduce it, I try to spend some time whenever it hangs to discover what is causing the problem. I have tried attaching a debugger to the running process using:

gdb /usr/bin/python -p 32489

but this only gives me the libc traceback such as:

0x00007fd2adbdb0fc in __libc_waitpid (pid=32490, stat_loc=stat_loc@entry=0x7ffd8aac545c,
    options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:31
31        return INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL);

From this output, I was able to find a similarly asked question which provided some useful advice, but ultimately did not help solve the problem. However, from reading another related informative post, I discovered that the Python debugger PDB can be used to solve this problem. So, my question is, how would I go about implementing PDB in a Python/Bottle application so when it occasionally hangs, I can get a python traceback?

One thing I have noted, is that when the hang happens, it seems the server thread turns into a zombie process, so it shows a defunc python process, while the other threads seem to continue to run. I have tried to use different web servers with Bottle, such as cherrypy and rocket, but both gave the same result.

Wes
  • 1,720
  • 3
  • 15
  • 26

0 Answers0