Snuyt said:
Well, that's the point. The card game doesn't have to do things but to
wait, and the cpu can process applications meanwhile. That's the kind of
'wait' I'm looking for.
The additional information helped. You can implement it however you want
but I (probably) wouldn't implement it that way. By having the thread pause
you "cannot" have the server do anything but wait... see the difference
between choosing not to do anything and can't do anything?
As I read it (and again, ignore it if this makes no sense or doesn't apply)
you want "2 seconds" to elapse but to conclude that nothing useful can occur
during that time is an error. You can send any number of messages (from the
server to the client) in that time. Importantly you could listen for
messages from the client during that time.
The server messages could update the clients with time remaining (or
something more sophisticated). Also two seconds is a little short it seems
to me. It could be longer and if the server was listening then all the
players could indicate they were ready and the server would deal right away.
Or the players could post "chat" to each other. You don't typically want to
tell the server to just wait and do nothing for two seconds.
threading.thread.sleep(2000) does the job well, assuming that the
processor can process other apps meanwhile.
The server "machine" continues to run and other apps continue to run. The
thread on your card game server does nothing. I assume it won't be informed
when one of the players quits out of the game during the time it is asleep.
You're describing the need for "2 seconds of not dealing cards" not 2
seconds of being oblivious to the world around it.
Tom