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

Threading issue in 2.0 #33

Closed
addyess opened this issue May 3, 2017 · 4 comments
Closed

Threading issue in 2.0 #33

addyess opened this issue May 3, 2017 · 4 comments

Comments

@addyess
Copy link
Contributor

addyess commented May 3, 2017

This test locks up in python2.7

def test_get_after_get_in_promise():
    def do(x):
        v = Promise.resolve("ok").then(lambda x: x).get()  # the wait inside get waits forever
        return v

    p = Promise.resolve(None).then(do)
    assert p.get() == "ok"
@addyess
Copy link
Contributor Author

addyess commented May 3, 2017

Could be related to: #30

@addyess
Copy link
Contributor Author

addyess commented May 4, 2017

The issue seems to be in here:

the Promise p executes function do in the context of the first drain_queue(self.normal_queue) when self.is_tick_used is set True

    def drain_queues(self):
        assert self.is_tick_used
        self.drain_queue(self.normal_queue)
        self.reset()
        self.have_drained_queues = True
        self.drain_queue(self.late_queue)

one global async_instance = Async(SyncScheduler()) is used for all promises.

when the inner Promise calls its .get() -- it blocks indefinitely for the async_instance to call the secondary promise's _settle_promise

This blocks the first call to drain_queues infinitely locking up all promises :)

@addyess
Copy link
Contributor Author

addyess commented May 4, 2017

here's a picture of the callstack as the inner .get is call
image

@syrusakbary
Copy link
Owner

This issue is now fixed in master

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