Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
19e51b14
Unverified
Commit
19e51b14
authored
3 years ago
by
reivilibre
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Manhole: wrap coroutines in `defer.ensureDeferred` automatically (#10602)
parent
0db8cab7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/10602.feature
+1
-0
1 addition, 0 deletions
changelog.d/10602.feature
docs/manhole.md
+1
-1
1 addition, 1 deletion
docs/manhole.md
synapse/util/manhole.py
+14
-0
14 additions, 0 deletions
synapse/util/manhole.py
with
16 additions
and
1 deletion
changelog.d/10602.feature
0 → 100644
+
1
−
0
View file @
19e51b14
The
Synapse
manhole
no
longer
needs
coroutines
to
be
wrapped
in
`defer.ensureDeferred`.
This diff is collapsed.
Click to expand it.
docs/manhole.md
+
1
−
1
View file @
19e51b14
...
@@ -67,7 +67,7 @@ This gives a Python REPL in which `hs` gives access to the
...
@@ -67,7 +67,7 @@ This gives a Python REPL in which `hs` gives access to the
`synapse.server.HomeServer`
object - which in turn gives access to many other
`synapse.server.HomeServer`
object - which in turn gives access to many other
parts of the process.
parts of the process.
Note that any call which returns a coroutine will need to be wrapped in
`ensureDeferred`
.
Note that
, prior to Synapse 1.41,
any call which returns a coroutine will need to be wrapped in
`ensureDeferred`
.
As a simple example, retrieving an event from the database:
As a simple example, retrieving an event from the database:
...
...
This diff is collapsed.
Click to expand it.
synapse/util/manhole.py
+
14
−
0
View file @
19e51b14
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
inspect
import
sys
import
sys
import
traceback
import
traceback
...
@@ -20,6 +21,7 @@ from twisted.conch.insults import insults
...
@@ -20,6 +21,7 @@ from twisted.conch.insults import insults
from
twisted.conch.manhole
import
ColoredManhole
,
ManholeInterpreter
from
twisted.conch.manhole
import
ColoredManhole
,
ManholeInterpreter
from
twisted.conch.ssh.keys
import
Key
from
twisted.conch.ssh.keys
import
Key
from
twisted.cred
import
checkers
,
portal
from
twisted.cred
import
checkers
,
portal
from
twisted.internet
import
defer
PUBLIC_KEY
=
(
PUBLIC_KEY
=
(
"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHhGATaW4KhE23+7nrH4jFx3yLq9OjaEs5
"
"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHhGATaW4KhE23+7nrH4jFx3yLq9OjaEs5
"
...
@@ -141,3 +143,15 @@ class SynapseManholeInterpreter(ManholeInterpreter):
...
@@ -141,3 +143,15 @@ class SynapseManholeInterpreter(ManholeInterpreter):
self
.
write
(
""
.
join
(
lines
))
self
.
write
(
""
.
join
(
lines
))
finally
:
finally
:
last_tb
=
ei
=
None
last_tb
=
ei
=
None
def
displayhook
(
self
,
obj
):
"""
We override the displayhook so that we automatically convert coroutines
into Deferreds. (Our superclass
'
displayhook will take care of the rest,
by displaying the Deferred if it
'
s ready, or registering a callback
if it
'
s not).
"""
if
inspect
.
iscoroutine
(
obj
):
super
().
displayhook
(
defer
.
ensureDeferred
(
obj
))
else
:
super
().
displayhook
(
obj
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment