Thanks for amazing tutorial! I am interested in asynchronous network programming for multiplayer games and yours is the best resource I encountered.
I run game_loop_wait.py with Python 3.5. I open the client page on a browser. Click on Connect. Get connecting, connected and game loop ticks messages. When I press keys I get Pressed Key Code: X messages from the server. Then after waiting more than a second get game loop ticks again. I can open the client on another tab and experience same stuff. Everything is fine up to this point.
Then if any of the clients click on Disconnect 1) game loop stops, 2) wshandler for new clients who connect after one client has disconnected hangs at await tick.acquire()
I added this print statement to game loop to see its stopping:
async def game_loop():
cnt = 0
while 1:
print('game loop tick no {}'.format(cnt))
cnt += 1
await tick.acquire()
tick.notify_all()
tick.release()
await asyncio.sleep(1)
And added this print statement to see where the handlers get stuck:
if not tick_task:
print('no tick task. await tick.acquire()')
await tick.acquire()
print('await tick.acquire() done')
tick_task = asyncio.ensure_future(tick.wait())
I'd like to solve the issue and send a PR however I have no former experience with asyncio. :-( Your previous examples allow disconnection and reconnection by the clients. Hence, I hope I didn't get the intention of example 3.4 incorrectly.
Have a good day!
Thanks for amazing tutorial! I am interested in asynchronous network programming for multiplayer games and yours is the best resource I encountered.
I run
game_loop_wait.pywith Python 3.5. I open the client page on a browser. Click onConnect. Getconnecting,connectedandgame loop ticksmessages. When I press keys I getPressed Key Code: Xmessages from the server. Then after waiting more than a second getgame loop ticksagain. I can open the client on another tab and experience same stuff. Everything is fine up to this point.Then if any of the clients click on
Disconnect1) game loop stops, 2)wshandlerfor new clients who connect after one client has disconnected hangs atawait tick.acquire()I added this
printstatement to game loop to see its stopping:And added this
printstatement to see where the handlers get stuck:I'd like to solve the issue and send a PR however I have no former experience with
asyncio. :-( Your previous examples allow disconnection and reconnection by the clients. Hence, I hope I didn't get the intention of example 3.4 incorrectly.Have a good day!