Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39582
| Path | csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <yueyoum@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.020 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'subject: + ': 0.07; '"run': 0.09; 'blocking': 0.09; 'expected.': 0.09; 'def': 0.10; 'import': 0.21; 'parse': 0.22; 'help.': 0.22; 'runs': 0.22; 'skip:[ 10': 0.26; 'tree': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'noticed': 0.28; 'run': 0.28; 'normally': 0.30; 'code': 0.31; 'running': 0.32; 'to:addr:python- list': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'problem,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'skip:u 20': 0.36; 'two': 0.37; 'why': 0.37; 'received:209': 0.37; 'to:addr:python.org': 0.39; 'here': 0.65; 'running!': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=yndm72461qGUqibuxKec/MY0k2cAKHANol64mIrMMlQ=; b=kuAsovoea6sAvDq35Zrq8ANzU/Yi8EnMbfUguSc17M70vzxIjOg/hkmBLYMeJb8c1D DpyJjEom54ITpmPbgeRfFgn0TEFomdr+QcF9y8Hlpkb1CIrGEQN5oKqT94g/Oh5Id2z+ c19PZEfvJS+6asfMvqTYN6eO2zFQ69KnjqWYF+v0OjL1Sgcmn9D5hYYThYWX3C32G9nM HbtsdRv1CWDwAm2Lykg4MbMKHLKkqZqbf4cU5A1XCnuRkkg9/MSHDrkHQW5z39x9TCYx U6C+lGiwbxjwV9XGJAVrgaDPN29e1yEYvl99HgIMgTJcBXKtKUFgNCBUD9fILtMx/WKW HrrQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.180.103.65 with SMTP id fu1mr4296591wib.4.1361547624462; Fri, 22 Feb 2013 07:40:24 -0800 (PST) |
| Date | Fri, 22 Feb 2013 23:40:24 +0800 |
| Subject | gevent + urllib2 blocking |
| From | 月忧茗 <yueyoum@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=f46d044401ca80385504d652028a |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2277.1361547632.2939.python-list@python.org> (permalink) |
| Lines | 73 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361547632 news.xs4all.nl 6974 [2001:888:2000:d::a6]:52005 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39582 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hi,
One problem, thanks for help.
import gevent.monkey
gevent.monkey.match_all()
from lxml import etree
# I using xpath parse the html
def _get(p):
url = BUILD_URL(p)
html = urllib2.urlopen(url)
# RUN AT HERE AND BLOCKING
# ver1
tree = etree.parse(html, parse)
# ver2
# tree = etree.fromstring(html.read(), parse)
....
workers = [gevent.spawn(_get, i) for i in xrange(1, 100)]
gevent.joinall(workers)
When using ver1, etree.parse(html, parse)
I noticed there are only two greenlets runs at "RUN AT HERE AND BLOCKING"
others are not running!
But, when I using ver2, this code will running normally as expected.
Why this ?
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
gevent + urllib2 blocking 月忧茗 <yueyoum@gmail.com> - 2013-02-22 23:40 +0800
csiph-web