From 599c65334fa131d7ee2f0cb9b9a5ccf1b7dc4d16 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 5 Oct 2020 08:56:49 -0400 Subject: [PATCH 1/2] Update manhole documentation for async/await. --- changelog.d/8462.doc | 1 + docs/manhole.md | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelog.d/8462.doc diff --git a/changelog.d/8462.doc b/changelog.d/8462.doc new file mode 100644 index 000000000000..cf84db6db7f2 --- /dev/null +++ b/changelog.d/8462.doc @@ -0,0 +1 @@ +Update the directions for using the manhole with coroutines. diff --git a/docs/manhole.md b/docs/manhole.md index 7375f5ad46c2..fc5a7ea8a864 100644 --- a/docs/manhole.md +++ b/docs/manhole.md @@ -35,9 +35,12 @@ This gives a Python REPL in which `hs` gives access to the `synapse.server.HomeServer` object - which in turn gives access to many other parts of the process. +Note that any call which returns a coroutine will need to be wrapped in `ensureDeferred`. + As a simple example, retrieving an event from the database: -``` ->>> hs.get_datastore().get_event('$1416420717069yeQaw:matrix.org') -> +```pycon +>>> from twisted.internet import defer +>>> defer.ensureDeferred(hs.get_datastore().get_event('$1416420717069yeQaw:matrix.org')) + ``` From 59d5f7e7ae162db26ef118c375dfe2d6c682c8f0 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 5 Oct 2020 09:11:45 -0400 Subject: [PATCH 2/2] It still returns a Deferred. --- docs/manhole.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/manhole.md b/docs/manhole.md index fc5a7ea8a864..75b6ae40e0cb 100644 --- a/docs/manhole.md +++ b/docs/manhole.md @@ -42,5 +42,5 @@ As a simple example, retrieving an event from the database: ```pycon >>> from twisted.internet import defer >>> defer.ensureDeferred(hs.get_datastore().get_event('$1416420717069yeQaw:matrix.org')) - +> ```