use ctx with cancel to (hopefully) avoid deadlocks
This commit is contained in:
parent
8d972ff74b
commit
1a27103347
6 changed files with 50 additions and 30 deletions
|
@ -20,17 +20,13 @@ import (
|
|||
func HandleDownloadRequest(
|
||||
bot *gotgbot.Bot,
|
||||
ctx *ext.Context,
|
||||
taskCtx context.Context,
|
||||
dlCtx *models.DownloadContext,
|
||||
) error {
|
||||
taskCtx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
dlCtx.Context = taskCtx
|
||||
|
||||
chatID := ctx.EffectiveMessage.Chat.Id
|
||||
if dlCtx.Extractor.Type == enums.ExtractorTypeSingle {
|
||||
TypingEffect(bot, ctx, chatID)
|
||||
err := HandleDefaultFormatDownload(bot, ctx, dlCtx)
|
||||
err := HandleDefaultFormatDownload(bot, ctx, taskCtx, dlCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue