Skip to content

Define concurrency model #8

@DavidLeoni

Description

@DavidLeoni

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions