Seems async / await are not so bad after all, I found out I can avoid async keyword poisoning - got some inspiration from Textual api
Will provide double use api: by default execution will be non-blocking, users will be optionally able to use await:
Default, non-blocking:
ada = Sprite()
ada.say("hello",3)
print("already done!")
Optional blocking behaviour:
ada = Sprite()
await ada.say("hello",3)
print("... after some time!")
Syncing between methods calls can still be done with usual asyncio functions, like gather:
ada = Sprite()
bob = Sprite()
await asyncio.gather(ada.slide(-100,0, 5),
bob.slide(-100,0, 3))
print("already done!")
Things still to consider:
Screen.register_shape and Screen.bgpic: in some way we should wait all resources are loaded
- tracing in goto commands
- normal methods, students may inadvertently treat them as awaitable
Seems
async/awaitare not so bad after all, I found out I can avoidasynckeyword poisoning - got some inspiration from Textual apiWill provide double use api: by default execution will be non-blocking, users will be optionally able to use
await:Default, non-blocking:
Optional blocking behaviour:
Syncing between methods calls can still be done with usual
asynciofunctions, likegather:Things still to consider:
Screen.register_shapeandScreen.bgpic: in some way we should wait all resources are loaded