MagicStack / MagicStack/asyncpg
Allow coroutines on add_listener.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 468
- PR merge metrics
- No merged PRs in 30d
Description
The current code that process a notification uses the method call_soon which expects a callable, why not to use create_task (or ensure_future for compatibility reasons) after checking if the callback is a coroutine?
There are different ways to do this, either just checking if the callback is a coroutine as described in here for example. Another way is just to add an extra argument or a different method to register coroutines.
Would it make sense to add a context? I am currently passing extra arguments to the callback via functools.partial.
Let me know if something like this would be accepted I can create a PR with the implementation.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the add_listener entry point and the notification processing that currently calls call_soon. Compare create_task and ensure_future for coroutine callbacks, including the existing functools.partial usage for extra arguments. Done should include an agreed callback API and compatibility behavior, with tests covering regular and coroutine listeners.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- api, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100