Path: csiph.com!usenet.pasdenom.info!aioe.org!newsfeed.x-privat.org!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'parser': 0.05; 'subject:Python': 0.05; 'bug.': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:library': 0.09; 'converting': 0.15; '"cached': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'html5lib': 0.16; 'safe,': 0.16; 'subject:html5lib': 0.16; 'url:issues': 0.16; "wouldn't": 0.17; 'url:blog': 0.17; 'rewrite': 0.18; 'subject:not': 0.19; 'header:In-Reply-To:1': 0.22; 'stefan': 0.24; 'fix': 0.25; 'code': 0.26; 'code,': 0.28; '(see': 0.28; 'url:code': 0.28; "i'm": 0.28; 'locks': 0.30; 'url:03': 0.30; 'url:2008': 0.30; 'url:detail': 0.30; 'xml': 0.31; 'subject:?': 0.31; 'thread': 0.32; "i've": 0.32; 'usual': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'it.': 0.33; 'header:X-Complaints- To:1': 0.34; 'backend': 0.34; 'to:addr:python-list': 0.35; '...': 0.35; 'trouble': 0.35; 'moving': 0.35; 'received:org': 0.36; 'run': 0.37; 'but': 0.37; 'url:org': 0.39; 'that.': 0.39; 'received:de': 0.39; 'to:addr:python.org': 0.40; 'john': 0.61; 'more': 0.61; 'your': 0.61; 'url:p': 0.62; 'subject:. ': 0.63; 'safe.': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: html5lib not thread safe. Is the Python SAX library thread-safe? Date: Mon, 12 Mar 2012 11:05:34 +0100 References: <4f5d0b82$0$11967$742ec2ed@news.sonic.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: fw-snc-frn5-de01.fw.telefonica.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 In-Reply-To: <4f5d0b82$0$11967$742ec2ed@news.sonic.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1331546749 news.xs4all.nl 6962 [2001:888:2000:d::a6]:45976 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21526 John Nagle, 11.03.2012 21:30: > "html5lib" is apparently not thread safe. > (see "http://code.google.com/p/html5lib/issues/detail?id=189") > Looking at the code, I've only found about three problems. > They're all the usual "cached in a global without locking" bug. > A few locks would fix that. > > But html5lib calls the XML SAX parser. Is that thread-safe? > Or is there more trouble down at the bottom? > > (I run a multi-threaded web crawler, and currently use BeautifulSoup, > which is thread safe, although dated. I'm looking at converting to > html5lib.) You may also consider moving to lxml. BeautifulSoup supports it as a parser backend these days, so you wouldn't even have to rewrite your code to use it. And performance-wise, well ... http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ Stefan