V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2017-03-10 11:16:38 +08:00 · 2670 次点击
    这是一个创建于 2596 天前的主题,其中的信息可能已经有所发展或是发生改变。

    场景是这样的:开启多个线程访问外部 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 条回复    2017-03-12 15:06:04 +08:00
    0asis
        1
    0asis  
       2017-03-10 11:21:15 +08:00
    看不懂- -,不过 OS 课本上说的是按照统一的顺序调用临界资源即可
    messense
        2
    messense  
       2017-03-12 15:06:04 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5597 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 03:34 · PVG 11:34 · LAX 20:34 · JFK 23:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.