Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12962

wrap the queue to multiprocess download

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!news.wiretrip.org!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <1248283536@qq.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'authority,': 0.09; 'query,': 0.09; 'skip:" 60': 0.09; 'output': 0.10; 'def': 0.15; '75,': 0.16; 'resp,': 0.16; 'subject:download': 0.16; 'to:name :python-list': 0.18; 'wrap': 0.18; '(most': 0.21; 'path,': 0.23; 'traceback': 0.24; 'string': 0.26; 'skip:_ 20': 0.28; 'skip:" 30': 0.28; 'typeerror:': 0.30; 'class': 0.30; 'to:addr:python-list': 0.33; 'last):': 0.34; 'file': 0.36; 'run': 0.37; 'header:Mime- Version:1': 0.39; 'to:addr:python.org': 0.39; 'download': 0.60; 'here': 0.65; 'subject: ': 0.73; ',the': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s0907; t=1315491146; bh=WBSkfpdNauFj5IP1UP2N9PyzHIxj1+DDn6x57SY0+Hc=; h=X-QQ-SSF:X-QQ-BUSINESS-ORIGIN:X-Originating-IP:X-QQ-STYLE: X-QQ-mid:From:To:Subject:Mime-Version:Content-Type: Content-Transfer-Encoding:Date:X-Priority:Message-ID:X-QQ-MIME: X-Mailer:X-QQ-Mailer; b=Vxa4DEXRut3MTNYPCC+RJ+kUswGubVLYzHYqhNicUn6iWo/UcoG/W+UUJHC7B+6kX OVwfthGokssjhxQ9GBvhDnIP5/exSAHElvZQBYBxEeR+STQJmUT41XWHrt767BC
X-QQ-SSF 00000000000000F0
X-QQ-BUSINESS-ORIGIN 2
X-Originating-IP 119.123.154.32
X-QQ-STYLE
X-QQ-mid webenglish1t1315491140t820294
From "alias" <1248283536@qq.com>
To "python-list" <python-list@python.org>
Subject wrap the queue to multiprocess download
Mime-Version 1.0
Content-Type multipart/alternative; boundary="----=_NextPart_4E68CD43_083F7070_7775022C"
Content-Transfer-Encoding 8Bit
Date Thu, 8 Sep 2011 22:12:19 +0800
X-Priority 3
X-QQ-MIME TCMime 1.0 by Tencent
X-Mailer QQMail 2.x
X-QQ-Mailer QQMail 2.x
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.875.1315491153.27778.python-list@python.org> (permalink)
Lines 97
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1315491153 news.xs4all.nl 2509 [2001:888:2000:d::a6]:42139
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12962

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

here is my part of program,you can see main structure,i want to wrap it in class ,
class   webdata(object):
    def  __init__(self,arg):
        jobs = Queue.Queue()
        for  x  in  name:
            jobs.put(self.url)
                
    
          
    def download(self):
        while not self.jobs.empty():
            url = self.jobs.get()
            hx = httplib2.Http()
            resp, content = hx.request(url, headers=headers).read()
            self.jobs.task_done()


    def  myrun(self):
        for i in range(30):
              threading.Thread(target=self.download).start()
        self.jobs.join()
    
if  __name__=="__main__":

    s=webdata('quote')
    s.myrun()

when it run ,the output is  :
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/pengtao/workspace/try.py", line 75, in download
    resp, content = hx.request(url, headers=headers).read()
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1288, in request
    (scheme, authority, request_uri, defrag_uri) = urlnorm(uri)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 201, in urlnorm
    (scheme, authority, path, query, fragment) = parse_uri(uri)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 197, in parse_uri
    groups = URI.match(uri).groups()
TypeError: expected string or buffer


when i use the same  structrue, don't   wrap it ,it can run .

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

wrap  the queue  to  multiprocess  download "alias" <1248283536@qq.com> - 2011-09-08 22:12 +0800

csiph-web