[GH-ISSUE #589] asynq.ProcessIn not delay work #284

Closed
opened 2026-03-02 05:20:11 +03:00 by kerem · 2 comments
Owner

Originally created by @kuangshp on GitHub (Dec 23, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/589

Originally assigned to: @hibiken on GitHub.

package main

import (
	"encoding/json"
	"fmt"
	"github.com/hibiken/asynq"
	"time"
)

type Person struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

func main() {
	client := asynq.NewClient(asynq.RedisClientOpt{
		Addr:     "127.0.0.1:6379",
		Password: "",
		DB:       0,
	})
	defer client.Close()

	person1, _ := json.Marshal(Person{Id: 1, Name: "hello"})
	task1 := asynq.NewTask("order", person1)
	var task1Info, _ = client.Enqueue(task1, asynq.ProcessIn(1*time.Hour))
	var p Person
	json.Unmarshal(task1Info.Payload, &p)
	fmt.Println(p.Name)
	time.Sleep(24 * time.Hour)
}

I want to use this package to do the task delay execution, but the execution is instantaneous, I don't know what is wrong

Originally created by @kuangshp on GitHub (Dec 23, 2022). Original GitHub issue: https://github.com/hibiken/asynq/issues/589 Originally assigned to: @hibiken on GitHub. ```go package main import ( "encoding/json" "fmt" "github.com/hibiken/asynq" "time" ) type Person struct { Id int `json:"id"` Name string `json:"name"` } func main() { client := asynq.NewClient(asynq.RedisClientOpt{ Addr: "127.0.0.1:6379", Password: "", DB: 0, }) defer client.Close() person1, _ := json.Marshal(Person{Id: 1, Name: "hello"}) task1 := asynq.NewTask("order", person1) var task1Info, _ = client.Enqueue(task1, asynq.ProcessIn(1*time.Hour)) var p Person json.Unmarshal(task1Info.Payload, &p) fmt.Println(p.Name) time.Sleep(24 * time.Hour) } ``` I want to use this package to do the task delay execution, but the execution is instantaneous, I don't know what is wrong
kerem 2026-03-02 05:20:11 +03:00
Author
Owner

@plum330 commented on GitHub (Sep 19, 2023):

I encounter this situation too.
version :latest

<!-- gh-comment-id:1724757306 --> @plum330 commented on GitHub (Sep 19, 2023): I encounter this situation too. version :latest
Author
Owner

@shohidul-se commented on GitHub (Jun 25, 2024):

facing this issue too, is there any solution?

<!-- gh-comment-id:2189875301 --> @shohidul-se commented on GitHub (Jun 25, 2024): facing this issue too, is there any solution?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#284
No description provided.