1818
1919from twisted .internet import defer
2020
21+ from synapse .metrics .background_process_metrics import run_as_background_process
2122from synapse .push .pusher import PusherFactory
2223from synapse .util .logcontext import make_deferred_yieldable , run_in_background
2324
@@ -122,8 +123,14 @@ def remove_pushers_by_access_token(self, user_id, access_tokens):
122123 p ['app_id' ], p ['pushkey' ], p ['user_name' ],
123124 )
124125
125- @defer .inlineCallbacks
126126 def on_new_notifications (self , min_stream_id , max_stream_id ):
127+ run_as_background_process (
128+ "on_new_notifications" ,
129+ self ._on_new_notifications , min_stream_id , max_stream_id ,
130+ )
131+
132+ @defer .inlineCallbacks
133+ def _on_new_notifications (self , min_stream_id , max_stream_id ):
127134 try :
128135 users_affected = yield self .store .get_push_action_users_in_range (
129136 min_stream_id , max_stream_id
@@ -147,8 +154,14 @@ def on_new_notifications(self, min_stream_id, max_stream_id):
147154 except Exception :
148155 logger .exception ("Exception in pusher on_new_notifications" )
149156
150- @defer .inlineCallbacks
151157 def on_new_receipts (self , min_stream_id , max_stream_id , affected_room_ids ):
158+ run_as_background_process (
159+ "on_new_receipts" ,
160+ self ._on_new_receipts , min_stream_id , max_stream_id , affected_room_ids ,
161+ )
162+
163+ @defer .inlineCallbacks
164+ def _on_new_receipts (self , min_stream_id , max_stream_id , affected_room_ids ):
152165 try :
153166 # Need to subtract 1 from the minimum because the lower bound here
154167 # is not inclusive
0 commit comments