[python-win32] Threading Issue
James Matthews
nytrokiss at gmail.com
Wed Jul 4 00:01:47 CEST 2007
Thanks
On 7/3/07, Jim Vickroy <Jim.Vickroy at noaa.gov> wrote:
>
> James Matthews wrote:
>
> Thanks Emlyn
>
> Just one more issue i have here. When i pass a string as an argument to
> the thread it seems to call the method returning the string as a tuple and i
> get an error that the method gets 48 arguments and it can only accept 2?
>
> If this doesn't make sense here is the code.
>
> for links in urls:
> links_thread = threading.Thread(target=self.next_page_finder,args=links)
> # Links is a string
>
> that argument (i.e., links) is expected to be a python tuple so what you
> need is:
> links_thread = threading.Thread(target=self.next_page_finder
> ,args=(links,))
>
> threaded_objects.append(links_thread)
> I get this error:
> Exception in thread Thread-1:
> Traceback (most recent call last):
> File "C:\Python25\lib\threading.py", line 460, in __bootstrap
> self.run()
> File "C:\Python25\lib\threading.py", line 440, in run
> self.__target(*self.__args, **self.__kwargs)
> TypeError: next_page_finder() takes exactly 2 arguments (48 given)
>
> Thanks
>
> James
>
>
> On 7/3/07, Emlyn Jones <emlynj at gmail.com> wrote:
> >
> > On 7/3/07, Emlyn Jones <emlynj at gmail.com> wrote:
> > > On 7/3/07, Tim Roberts <timr at probo.com> wrote:
> > > James Matthews wrote:
> > > > > So i need to make the list a global variable
> > > >
> > > > No, that's not what he did at all. The names just happened to be
> > the
> > > > same, that's all. Consider it this way:
> > > >
> > > > import threading
> > > > def foo( threadresult ):
> > > > threadresult.extend( range(4) )
> > > >
> > > > result = list()
> > > > thread = threading.Thread (target=foo, args=(result,))
> > > > thread.start()
> > > > result
> > > >
> >
> > How about using an object derived from Thread and making 'result' a
> > member of it?
> >
> > http://docs.python.org/lib/thread-objects.html
> >
> > You'd probably also want a variable to tell you if the function has
> > finished.
> >
> > --
> > () ascii ribbon campaign - against html e-mail
> > /\ www.asciiribbon.org - against proprietary attachments
> > _______________________________________________
> > Python-win32 mailing list
> > Python-win32 at python.org
> > http://mail.python.org/mailman/listinfo/python-win32
> >
>
>
>
> --
> http://www.goldwatches.com/watches.asp?Brand=14
> http://www.jewelerslounge.com
>
> ------------------------------
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.orghttp://mail.python.org/mailman/listinfo/python-win32
>
>
>
--
http://www.goldwatches.com/watches.asp?Brand=14
http://www.jewelerslounge.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20070703/1e761443/attachment.htm
More information about the Python-win32
mailing list