@@ -332,8 +332,7 @@ def is_running(self):
332
332
"""
333
333
return self ._db_pool .running
334
334
335
- @defer .inlineCallbacks
336
- def _check_safe_to_upsert (self ):
335
+ async def _check_safe_to_upsert (self ):
337
336
"""
338
337
Is it safe to use native UPSERT?
339
338
@@ -342,7 +341,7 @@ def _check_safe_to_upsert(self):
342
341
343
342
If the background updates have not completed, wait 15 sec and check again.
344
343
"""
345
- updates = yield self .simple_select_list (
344
+ updates = await self .simple_select_list (
346
345
"background_updates" ,
347
346
keyvalues = None ,
348
347
retcols = ["update_name" ],
@@ -614,8 +613,7 @@ def interaction(txn):
614
613
# "Simple" SQL API methods that operate on a single table with no JOINs,
615
614
# no complex WHERE clauses, just a dict of values for columns.
616
615
617
- @defer .inlineCallbacks
618
- def simple_insert (self , table , values , or_ignore = False , desc = "simple_insert" ):
616
+ async def simple_insert (self , table , values , or_ignore = False , desc = "simple_insert" ):
619
617
"""Executes an INSERT query on the named table.
620
618
621
619
Args:
@@ -631,7 +629,7 @@ def simple_insert(self, table, values, or_ignore=False, desc="simple_insert"):
631
629
`or_ignore` is True
632
630
"""
633
631
try :
634
- yield self .runInteraction (desc , self .simple_insert_txn , table , values )
632
+ await self .runInteraction (desc , self .simple_insert_txn , table , values )
635
633
except self .engine .module .IntegrityError :
636
634
# We have to do or_ignore flag at this layer, since we can't reuse
637
635
# a cursor after we receive an error from the db.
@@ -684,8 +682,7 @@ def simple_insert_many_txn(txn, table, values):
684
682
685
683
txn .executemany (sql , vals )
686
684
687
- @defer .inlineCallbacks
688
- def simple_upsert (
685
+ async def simple_upsert (
689
686
self ,
690
687
table ,
691
688
keyvalues ,
@@ -714,14 +711,14 @@ def simple_upsert(
714
711
inserting
715
712
lock (bool): True to lock the table when doing the upsert.
716
713
Returns:
717
- Deferred( None or bool) : Native upserts always return None. Emulated
714
+ None or bool: Native upserts always return None. Emulated
718
715
upserts return True if a new entry was created, False if an existing
719
716
one was updated.
720
717
"""
721
718
attempts = 0
722
719
while True :
723
720
try :
724
- result = yield self .runInteraction (
721
+ return await self .runInteraction (
725
722
desc ,
726
723
self .simple_upsert_txn ,
727
724
table ,
@@ -730,7 +727,6 @@ def simple_upsert(
730
727
insertion_values ,
731
728
lock = lock ,
732
729
)
733
- return result
734
730
except self .engine .module .IntegrityError as e :
735
731
attempts += 1
736
732
if attempts >= 5 :
@@ -1121,8 +1117,7 @@ def simple_select_list_txn(cls, txn, table, keyvalues, retcols):
1121
1117
1122
1118
return cls .cursor_to_dict (txn )
1123
1119
1124
- @defer .inlineCallbacks
1125
- def simple_select_many_batch (
1120
+ async def simple_select_many_batch (
1126
1121
self ,
1127
1122
table ,
1128
1123
column ,
@@ -1156,7 +1151,7 @@ def simple_select_many_batch(
1156
1151
it_list [i : i + batch_size ] for i in range (0 , len (it_list ), batch_size )
1157
1152
]
1158
1153
for chunk in chunks :
1159
- rows = yield self .runInteraction (
1154
+ rows = await self .runInteraction (
1160
1155
desc ,
1161
1156
self .simple_select_many_txn ,
1162
1157
table ,
0 commit comments