MagicStack / MagicStack/asyncpg

Allow coroutines on add_listener.

Offen
#546 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
8.1k
Forks
468
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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](https://stackoverflow.com/questions/36076619/test-if-function-or-method-is-normal-or-asynchronous) 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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
postgresql, python
Bereich
api, database
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
32/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.