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
|
@ -1,9 +1,11 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"govd/bot/core"
|
||||
"govd/database"
|
||||
extractors "govd/ext"
|
||||
"time"
|
||||
|
||||
"github.com/PaulSonOfLars/gotgbot/v2"
|
||||
"github.com/PaulSonOfLars/gotgbot/v2/ext"
|
||||
|
@ -39,7 +41,12 @@ func URLHandler(bot *gotgbot.Bot, ctx *ext.Context) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
err = core.HandleDownloadRequest(bot, ctx, dlCtx)
|
||||
|
||||
taskCtx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
err = core.HandleDownloadRequest(
|
||||
bot, ctx, taskCtx, dlCtx)
|
||||
if err != nil {
|
||||
core.HandleErrorMessage(
|
||||
bot, ctx, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue