Skip to content

feat: Add cancel_job() method to JobManager #1228

Open

Description

@nightfury-devai

Is there an existing issue for this?

I have searched the existing issues and found none.

Problem Statement

In src/codegraphcontext/core/jobs.py, the JobStatus enum has a CANCELLED status defined but there is no cancel_job() method in the JobManager class to actually use it. This means once a job is started it cannot be cancelled programmatically.

Proposed Solution

Add a cancel_job() method to JobManager that sets the job status to JobStatus.CANCELLED and sets the end_time. This is thread-safe using the existing self.lock pattern.

Example:

def cancel_job(self, job_id: str) -> bool:
with self.lock:
if job_id in self.jobs:
job = self.jobs[job_id]
if job.status in [JobStatus.PENDING, JobStatus.RUNNING]:
job.status = JobStatus.CANCELLED
job.end_time = datetime.now()
return True
return False

Benefits

Allows users to cancel long-running indexing jobs
Makes use of the existing CANCELLED status that is currently unused
Consistent with the existing thread-safe pattern in JobManager

Record

I agree to follow this project's Code of Conduct
I want to work on this issue

Activity

  1. github-actions commented on Jun 13, 2026

    @github-actions
    Contributor

    Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

  2. moved this from Backlog tasks to In progress in CGC Progress Boardon Jul 29, 2026
  3. added
    gssoc:approvedGSSoC validation: counts toward scoring
    level:beginnerGSSoC difficulty: 20 pts contributor / 10 mentor
    mentor:Shashankss1205GSSoC mentor attribution: credits reviewing mentor
    type:featureGSSoC type bonus: feature
    on Sep 24, 2026
  4. Shashankss1205 commented on Oct 15, 2026

    @Shashankss1205
    Collaborator

    Maintenance review — 15 October 2026

    A status-only cancel_job() would be overwritten by ongoing indexing and would not stop work. Keep this open for cooperative cancellation checks in both pipelines and tests that terminal CANCELLED jobs cannot become COMPLETED.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gssoc:approvedGSSoC validation: counts toward scoringlevel:beginnerGSSoC difficulty: 20 pts contributor / 10 mentormentor:Shashankss1205GSSoC mentor attribution: credits reviewing mentortype:featureGSSoC type bonus: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions