#Strange behavior related to awaited SceneTreeTimer in array of callables

1 messages · Page 1 of 1 (latest)

grave nimbus
#

I'm trying to create a system related to UI where multiple objects are awaiting user input at once, and ran into a confusing issue here related to timers I was using to test it. I can't tell what's wrong here.

#

If only test_func_2 is added to the list of callables, it resolves as expected: "test done" and "all awaits done" print. But with the timer in test_func_1, it doesn't resolve.

tame bane
#

I feel like that while loop is going to lock up your game. You need to rely on signals, not a while loop

#

test_func_2 doesn't have anything that needs awaited, which is why it works fine. The fact that test_func_1 actually uses something that needs awaited means your while loop locks up the entire game and prevents anything else from ever happening

#

Instead of using a while loop, you could do that completion check in _process. This would allow the game to keep running and you would just check for completion each frame

grave nimbus
#

After talking about it with some buddies that's sort of what I ended up with- the only change was to replace line 21 with await get_tree().process_frame

#

I was mistaken in how await functions; I was under the assumption that it allowed for coroutines

tame bane
#

await does allow for coroutines, but it doesn't create threads. An endless while loop on the main thread will lock up the entire game