Skip to content

Issue canceling jobs with Reference #84

Description

@finity84

I had issue canceling jobs until I tried LLM's fix, which points to a potential mismatch in the source code, see below


The cancel method in ProcessExecutor fails to cancel running jobs because of a type mismatch in the pids_for_job dict lookup.

In job_wrapper, the PID is stored using job.id (a string):

pids_for_job[job.id] = os.getpid()

But in cancel, the lookup uses ref.identifier (always a UUID):

pid = self.pids_for_job.get(ref.identifier)

Since Reference.__init__ always converts to UUID:

def __init__(self, identifier: str | UUID):
    if isinstance(identifier, UUID):
        self.identifier = identifier
    else:
        self.identifier = UUID(identifier)

The lookup fails because '03ee1a46-...' (string key) != UUID('03ee1a46-...') (UUID lookup).

Fix:

pid = self.pids_for_job.get(str(ref.identifier))

Debug output confirming the issue:

cancel called with ref.identifier=03ee1a46-9253-bb07-b15d-7ba2503352c2, type=<class 'uuid.UUID'>
pids_for_job keys: ['03ee1a46-9253-bb07-b15d-7ba2503352c2']
looked up pid: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions