推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
cloudyplain
V2EX  ›  Python

Python 多线程死锁

  •  
  •   cloudyplain · Mar 10, 2017 · 3609 views
    This topic created in 3500 days ago, the information mentioned may be changed or developed.

    场景是这样的:开启多个线程访问外部 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 引发的死锁,不知道大家没有遇到这个坑,请大家帮忙给些建议,谢谢!

    2 replies  •  2017-03-12 15:06:04 +08:00
    0asis
        1
    0asis  
       Mar 10, 2017
    看不懂- -,不过 OS 课本上说的是按照统一的顺序调用临界资源即可
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4074 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 00:53 · PVG 08:53 · LAX 17:53 · JFK 20:53
    ♥ Do have faith in what you're doing.