oleander-whirlwind
10/06/2025, 12:05 PMMarvin
10/06/2025, 12:05 PMMarvin
10/06/2025, 12:08 PMdone, not_done), and the resolver passes a single iterable instead—hence the TypeError.
Why it happens:
- After your tasks finish, Prefect tries to resolve the flow’s return value into final states.
- If the return value is a DoneAndNotDoneFutures (from either concurrent.futures.wait or prefect.futures.wait), Prefect’s collection visitor reconstructs it with type(seq)(items) instead of unpacking it as two args, which causes:
TypeError: DoneAndNotDoneFutures.__new__() missing 1 required positional argument: 'not_done'
What to do now (workarounds):
- Don’t return the DoneAndNotDoneFutures object directly. Return a plain tuple or dict instead.
For example, if you’re using Prefect 3.x:
from prefect.futures import wait
done, not_done = wait(futures, return_when="ALL_COMPLETED")
# Option 1: just return the finished items
return list(done)
# Option 2: return a simple structure
return {"done": list(done), "not_done": list(not_done)}
If you’re using concurrent.futures.wait, do the same shape conversion:
from concurrent.futures import wait, ALL_COMPLETED
done, not_done = wait(futures, return_when=ALL_COMPLETED)
return {"done": list(done), "not_done": list(not_done)}
A couple of checks:
- You appear to be on Python 3.13 (/site-packages/.../python3.13/). Prefect 3.x hasn’t officially supported 3.13 yet. If possible, try Python 3.10–3.12 and the latest Prefect 3.x release.
- Make sure you’re on the latest Prefect; there have been updates around futures and wait (Prefect futures API, source).
If you can share:
- The exact line you return from the flow (especially if it’s the output of `wait`/`as_completed`)
- Your Prefect and Python versions
…I can confirm whether this is a pure return-shape issue or a bug specific to your version/environment. If it reproduces on the latest Prefect with Python 3.12, I’m happy to file a bug upstream.