[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] using urllib



Thanks Sami.

I also took a look at SolarWolf, which has some urllib code to fetch
"News" in gamenews.py.  Looks like it writes the info to a file and lets
the OS deal with the concurrency issues.

I think Queue will be more suited to my needs.

-sjbrown

On Tue, 19 Apr 2005, Sami Hangaslammi wrote:

> On 4/19/05, Shandy Brown <sjbrown@xxxxxxxxx> wrote:
> > can anyone recommend any strategies for using urllib for doing simple
> > pulling of information with pygame?
> >
> > the urlopen and urlretrieve functions block, which is not ideal for
> > pygame apps.  how have people dealt with this, by starting a Thread?
> >
> > If a Thread was used, how has the info been put back into the pygame
> > mainloop?  Can you put an event on the pygame event queue from the new
> > thread?
>
>
> If you are using urllib, your only choice is to put it in a separate
> thread. The document doesn't really mention anything about the thread
> safety of the pygame.event module, so I would assume the worst. The
> easiest and safest way to pass the data between the threads is
> probably by using the Queue module from Python
> (http://www.python.org/doc/2.4.1/lib/module-Queue.html).
>
> --
> Sami Hangaslammi
>