Behavior of then() for a resolved promise?

Open
#7 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start at the promise(val) resolution path and then(), then trace how Celery's EagerResult uses its already-fired on_ready promise. Define and verify the behavior for adding callbacks after resolution, including the callback chain and repeated resolution noted in the issue.

Written by the indexing model from the issue text.

Description

What's the expected behavior for calling then() on a resolved promise? Right now you add callbacks that will never get called.

E.g. using an EagerResult in celery you end up with something like this:

val = 40
result = EagerResult(val)
# Internally result.on_ready is a promise that has already fired, e.g. promise(val) is called.
result.then(callback, errback)
# Neither of these will ever fire.

I'd expect adding a callback to an already resolved promise to call it immediately.

Note that Twisted will immediately run your callbacks if a Deferred already has resolved, so I'm expecting the same behavior here.

(As an aside -- I find it odd you can resolve a promise multiple times...but it doesn't seem to have the same callback chain.)

Dominant language
Python
Stars
129
Forks
48
Avg merge
13h 35m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from celery/vine

All issues in celery/vine

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.