Don't unnecessarily start bg process while handling typing. (#8668)

There's no point starting a background process when all its going to do is bail if federation isn't enabled.
This commit is contained in:
Erik Johnston 2020-10-27 15:32:19 +00:00 committed by GitHub
parent 9b7c28283a
commit 0c7f9cb81f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

1
changelog.d/8668.misc Normal file
View file

@ -0,0 +1 @@
Reduce number of OpenTracing spans started.

View file

@ -167,20 +167,25 @@ class FollowerTypingHandler:
now_typing = set(row.user_ids) now_typing = set(row.user_ids)
self._room_typing[row.room_id] = row.user_ids self._room_typing[row.room_id] = row.user_ids
if self.federation:
run_as_background_process( run_as_background_process(
"_handle_change_in_typing", "_send_changes_in_typing_to_remotes",
self._handle_change_in_typing, self._send_changes_in_typing_to_remotes,
row.room_id, row.room_id,
prev_typing, prev_typing,
now_typing, now_typing,
) )
async def _handle_change_in_typing( async def _send_changes_in_typing_to_remotes(
self, room_id: str, prev_typing: Set[str], now_typing: Set[str] self, room_id: str, prev_typing: Set[str], now_typing: Set[str]
): ):
"""Process a change in typing of a room from replication, sending EDUs """Process a change in typing of a room from replication, sending EDUs
for any local users. for any local users.
""" """
if not self.federation:
return
for user_id in now_typing - prev_typing: for user_id in now_typing - prev_typing:
if self.is_mine_id(user_id): if self.is_mine_id(user_id):
await self._push_remote(RoomMember(room_id, user_id), True) await self._push_remote(RoomMember(room_id, user_id), True)