Skip to content

Commit 215f077

Browse files
committed
Make forward backfill timeout configurable
1 parent 4e4f409 commit 215f077

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

mautrix_telegram/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def do_update(self, helper: ConfigUpdateHelper) -> None:
194194
copy("bridge.backfill.forward_limits.sync.normal_group")
195195
copy("bridge.backfill.forward_limits.sync.supergroup")
196196
copy("bridge.backfill.forward_limits.sync.channel")
197+
copy("bridge.backfill.forward_timeout")
197198
copy("bridge.backfill.incremental.messages_per_batch")
198199
copy("bridge.backfill.incremental.post_batch_delay")
199200
copy("bridge.backfill.incremental.max_batches.user")

mautrix_telegram/example-config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ bridge:
420420
normal_group: 100
421421
supergroup: 100
422422
channel: 100
423+
# Timeout for forward backfills in seconds. If you have a high limit, you'll have to increase this too.
424+
forward_timeout: 900
423425

424426
# Settings for incremental backfill of history. These only apply when using MSC2716.
425427
incremental:

mautrix_telegram/portal.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -2885,13 +2885,15 @@ async def forward_backfill(
28852885
)
28862886
if limit == 0:
28872887
return "Limit is zero, not backfilling"
2888+
timeout = self.config["bridge.backfill.forward_timeout"]
28882889
with self.backfill_lock:
2889-
output = await asyncio.wait_for(
2890-
self.backfill(
2891-
source, client, forward=True, forward_limit=limit, last_tgid=last_tgid
2892-
),
2893-
timeout=15 * 60,
2890+
task = self.backfill(
2891+
source, client, forward=True, forward_limit=limit, last_tgid=last_tgid
28942892
)
2893+
if timeout > 0:
2894+
output = await asyncio.wait_for(task, timeout=timeout)
2895+
else:
2896+
output = await task
28952897
self.log.debug(f"Forward backfill complete, status: {output}")
28962898
return output
28972899

0 commit comments

Comments
 (0)