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

Re: [pygame] SOC Proposal: Networking for Pygame



You're right. It's been a year or so since I've written any pygame code, my API memory isn't so good it seems.

-bob

On May 8, 2006, at 3:36 AM, Frode Jensen wrote:

According to the documentation pygame.event.get doesn't block, pygame.event.wait does. This is still a concern though, since users would believe that networking events act like any other event, and pygame.event.wait would be a natural thing to use in a turn-based game.

Like Bob said, it doesn't look like SDL has any event mechanism with a timeout.. so a threaded module may be the best option anyway.

-Frode

Bob Ippolito wrote:

On May 7, 2006, at 11:17 PM, Simon Wittber wrote:

On 5/8/06, Bob Ippolito <bob@xxxxxxxxxx> wrote:
This looks pretty good. One thing to note however is that you're
going to need to do the select() in a separate thread if you want it
to be able to wake up the event loop on network events. Depending on
the way you're using the pygame event loop, this might not work out
so well.

AFAIK, the select.select call doesn't block, which is the only reason
(that I know of) that It would need to be called in a seperate thread?
I'm not sure exactly what you mean by this.

select.select blocks exactly no longer than you ask it to. pygame.event.get blocks until it gets an event. For an application that mostly just waits for events (mouse, keyboard) via pygame.event.get is not going to interoperate well with network events if it only polls the network after some user input. Ideally for those sorts of applications you would like the network to also send an event asynchronously to wake up the event loop. That is only possible with an additional thread given how SDL works.


-bob