推荐学习书目
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
tdifg
V2EX  ›  Python

一开多线程用 pycurl 就挂?

  •  
  •   tdifg · Oct 27, 2015 · 4212 views
    This topic created in 3862 days ago, the information mentioned may be changed or developed.

    最近赶个工,需要取延时信息,所以必须用 curl 。

    核心部分很简单,就是多线程(我用了 threadpool)用 curl 跑 url 列表,结果我这里经常直接 exit code 139 ,看下 core dump ,貌似是 perform 过程中挂的。磨蹭了一上午,一气之下直接换用了 for 循环……竟然就正常了
    你们碰过这种事吗?

    6 replies    2015-12-14 12:39:48 +08:00
    loqixh
        1
    loqixh  
       Oct 27, 2015
    libcurl 的多线程有点麻烦,很多库没处理。。。。。。。退出正常
    dai269619118
        2
    dai269619118  
       Oct 27, 2015
    我用进程池跑 pycurl 也有这个问题- -
    tdifg
        3
    tdifg  
    OP
       Oct 28, 2015
    @dai269619118
    @loqixh 我从某个犄角旮旯里翻了个设置:
    c.setopt(pycurl.NOSIGNAL, True)
    加上这个就没问题了,没有测试其他库,至少用 threadpool 是正常了。
    不清楚为啥,以后有空该读读 threadpool 代码。
    dai269619118
        4
    dai269619118  
       Oct 28, 2015
    @tdifg 擦 我加上试试
    tdifg
        5
    tdifg  
    OP
       Dec 14, 2015
    @dai269619118
    @loqixh
    然而,一个月过去了,程序前几天突然挂了,看了下进程状态,应该是多线程出了问题。所以,最好不要多线程调 pycurl 。
    唉……
    dai269619118
        6
    dai269619118  
       Dec 14, 2015
    @tdifg 现在用 supervisor 管理起来 还没出现过问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2996 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 08:55 · PVG 16:55 · LAX 01:55 · JFK 04:55
    ♥ Do have faith in what you're doing.