cspotcode / cspotcode/py_game_coroutines

Support async/await syntax

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2
Forks
2
PR merge metrics
No merged PRs in 30d

Description

`async def ` is more explicit and obvious for declaring a coroutine than a normal `def` with yield statements inside it.

`await other_coroutine()` is a bit nicer than `yield from`

Cons:
users might get confused and believe (incorrectly) that this behaves like asyncio stuff, or that they can use stuff like asyncio.sleep()

---

To support async/await, the context helpers need to return values that are both generators and awaitable. Currently they return generators.

A wrapper like this might work:

```python
class AwaitableGenerator:
def __init__(self, generator):
self._g = generator
def __await__(self):
return self._g
def __iter__(self):
return self._g
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.