Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior of then() for a resolved promise? #7

Open
clokep opened this issue Feb 1, 2017 · 3 comments
Open

Behavior of then() for a resolved promise? #7

clokep opened this issue Feb 1, 2017 · 3 comments

Comments

@clokep
Copy link

clokep commented Feb 1, 2017

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.)

@auvipy
Copy link
Member

auvipy commented Nov 10, 2021

whats your current thoughts on this?

@clokep
Copy link
Author

clokep commented Nov 10, 2021

whats your current thoughts on this?

My thought is that it is confusing that the callbacks never get called, but it is unclear what should happen. This package sadly lacks any documentation of the expected behaviors.

@auvipy
Copy link
Member

auvipy commented Nov 10, 2021

some little addition e881321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants