#10527·dspy

[Bug] ParallelExecutor drops a task result equal to "cancelled"

Author: dafyy321-pixelCreated Sep 29, 2026Updated Sep 29, 2026

What happened?

ParallelExecutor can lose a successful task result when the task returns the string "cancelled". The one-thread path returns that string unchanged; the multi-threaded path reports None for the same input and callback. There is no cancellation request and no exception in this case. The value happens to collide with a private marker used by the executor.

The failure is silent. Code that uses short status strings as results can see a missing value simply because it increases num_threads, even though the worker finished normally. The output list keeps its length and position, which makes this look like an ordinary None result rather than a dropped value.

Steps to reproduce

python
from dspy.utils.parallelizer import ParallelExecutor

items = ["cancelled", "completed"]
for num_threads in (1, 3):
    executor = ParallelExecutor(num_threads=num_threads, disable_progress_bar=True)
    print(num_threads, executor.execute(lambda item: item, items))

On main at 9c900c7:

1 ['cancelled', 'completed']
3 [None, 'completed']

Both executions should return ['cancelled', 'completed']. The task is an identity function, so there is no application-level interpretation of the word "cancelled" in the example. The thread count alone selects the path that drops it.

Where the result goes

The multi-threaded path sets job_cancelled = "cancelled" for a job skipped after a cancellation request. A worker that actually runs returns its function result instead. When futures complete, the collector at line 199 records an outcome only if outcome != job_cancelled. For a normal result equal to "cancelled", that condition is false, so the result slot remains _UNSET. The return at line 238 converts _UNSET to None.

The private marker should be distinguishable from every value a caller can return. PR #10526 changes it to a unique object and compares by identity. Its regression test checks the same string result with one and three threads.

Environment

  • DSPy 3.4.0, repository main at 9c900c7
  • Reproduced with Python 3.11 on Windows; no model, API key, or external service is involved