[PR #145] [MERGED] Make sure to invoke CancelFunc in all cases #632

Closed
opened 2026-03-02 05:54:21 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hibiken/asynq/pull/145
Author: @hibiken
Created: 5/3/2020
Status: Merged
Merged: 5/3/2020
Merged by: @hibiken

Base: masterHead: fix/context


📝 Commits (1)

  • 8356218 Make sure to invoke CancelFunc in all cases

📊 Changes

1 file changed (+6 additions, -4 deletions)

View changed files

📝 processor.go (+6 -4)

📄 Description

From context package overview:

The WithCancel, WithDeadline, and WithTimeout functions take a Context (the parent) and return a derived Context (the child) and a CancelFunc. Calling the CancelFunc cancels the child and its children, removes the parent's reference to the child, and stops any associated timers. Failing to call the CancelFunc leaks the child and its children until the parent is canceled or the timer fires. The go vet tool checks that CancelFuncs are used on all control-flow paths.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hibiken/asynq/pull/145 **Author:** [@hibiken](https://github.com/hibiken) **Created:** 5/3/2020 **Status:** ✅ Merged **Merged:** 5/3/2020 **Merged by:** [@hibiken](https://github.com/hibiken) **Base:** `master` ← **Head:** `fix/context` --- ### 📝 Commits (1) - [`8356218`](https://github.com/hibiken/asynq/commit/835621832979b5ce9d5038898f9b80a3962921be) Make sure to invoke CancelFunc in all cases ### 📊 Changes **1 file changed** (+6 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `processor.go` (+6 -4) </details> ### 📄 Description From context package overview: > The WithCancel, WithDeadline, and WithTimeout functions take a Context (the parent) and return a derived Context (the child) and a CancelFunc. Calling the CancelFunc cancels the child and its children, removes the parent's reference to the child, and stops any associated timers. **Failing to call the CancelFunc leaks the child and its children until the parent is canceled or the timer fires.** The go vet tool checks that CancelFuncs are used on all control-flow paths. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 05:54:21 +03:00
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#632
No description provided.