Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

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

Merged
merged 3 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8668.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't unnecessarily start bg process while handling typing.
21 changes: 13 additions & 8 deletions synapse/handlers/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,25 @@ def process_replication_rows(
now_typing = set(row.user_ids)
self._room_typing[row.room_id] = row.user_ids

run_as_background_process(
"_handle_change_in_typing",
self._handle_change_in_typing,
row.room_id,
prev_typing,
now_typing,
)
if self.federation:
run_as_background_process(
"_send_changes_in_typing_to_remotes",
self._send_changes_in_typing_to_remotes,
row.room_id,
prev_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]
):
"""Process a change in typing of a room from replication, sending EDUs
for any local users.
"""

if not self.federation:
return

for user_id in now_typing - prev_typing:
if self.is_mine_id(user_id):
await self._push_remote(RoomMember(room_id, user_id), True)
Expand Down