场景是这样的:开启多个线程访问外部 api ,过一段时间,发现所有线程死锁。 环境: python2.6.7 centos7.1 urllib2 , suse 下无此问题。 dump 如下:
Thread 161 (Thread 0x7f80de4e9700 (LWP 12459)):
#0 0x00007f80e4cacb6c in __lll_lock_wait_private () from /lib64/libc.so.6
#1 0x00007f80e4cc2efd in _L_lock_746 () from /lib64/libc.so.6
#2 0x00007f80e4cc2cb5 in __check_pf () from /lib64/libc.so.6
#3 0x00007f80e4c88f69 in getaddrinfo () from /lib64/libc.so.6
#4 0x00007f80e12faa3c in socket_getaddrinfo (self=<optimized out>, args=<optimized out>) at /home/basic/Python-2.7.6/Modules/socketmodule.c:4198
#5 0x00000000004b5726 in call_function (oparg=<optimized out>, pp_stack=0x7f80de4e6b30) at Python/ceval.c:4021
#6 PyEval_EvalFrameEx (f=f@entry=0x7f7fa403c980, throwflag=throwflag@entry=0) at Python/ceval.c:2666
看上去是 getaddrinfo 引发的死锁,不知道大家没有遇到这个坑,请大家帮忙给些建议,谢谢!
1
0asis 2017-03-10 11:21:15 +08:00
看不懂- -,不过 OS 课本上说的是按照统一的顺序调用临界资源即可
|
2
messense 2017-03-12 15:06:04 +08:00
|