35
35
from typing_extensions import Literal
36
36
37
37
from twisted .enterprise import adbapi
38
- from twisted .internet import defer
39
38
40
39
from synapse .api .errors import StoreError
41
40
from synapse .config .database import DatabaseConnectionConfig
@@ -507,8 +506,9 @@ def new_transaction(
507
506
self ._txn_perf_counters .update (desc , duration )
508
507
sql_txn_timer .labels (desc ).observe (duration )
509
508
510
- @defer .inlineCallbacks
511
- def runInteraction (self , desc : str , func : Callable , * args : Any , ** kwargs : Any ):
509
+ async def runInteraction (
510
+ self , desc : str , func : Callable , * args : Any , ** kwargs : Any
511
+ ) -> Any :
512
512
"""Starts a transaction on the database and runs a given function
513
513
514
514
Arguments:
@@ -521,7 +521,7 @@ def runInteraction(self, desc: str, func: Callable, *args: Any, **kwargs: Any):
521
521
kwargs: named args to pass to `func`
522
522
523
523
Returns:
524
- Deferred: The result of func
524
+ The result of func
525
525
"""
526
526
after_callbacks = [] # type: List[_CallbackListEntry]
527
527
exception_callbacks = [] # type: List[_CallbackListEntry]
@@ -530,16 +530,14 @@ def runInteraction(self, desc: str, func: Callable, *args: Any, **kwargs: Any):
530
530
logger .warning ("Starting db txn '%s' from sentinel context" , desc )
531
531
532
532
try :
533
- result = yield defer .ensureDeferred (
534
- self .runWithConnection (
535
- self .new_transaction ,
536
- desc ,
537
- after_callbacks ,
538
- exception_callbacks ,
539
- func ,
540
- * args ,
541
- ** kwargs
542
- )
533
+ result = await self .runWithConnection (
534
+ self .new_transaction ,
535
+ desc ,
536
+ after_callbacks ,
537
+ exception_callbacks ,
538
+ func ,
539
+ * args ,
540
+ ** kwargs
543
541
)
544
542
545
543
for after_callback , after_args , after_kwargs in after_callbacks :
0 commit comments