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

Nested promise never complete with all #10

Open
joshuaavalon opened this issue Dec 29, 2017 · 3 comments
Open

Nested promise never complete with all #10

joshuaavalon opened this issue Dec 29, 2017 · 3 comments

Comments

@joshuaavalon
Copy link

joshuaavalon commented Dec 29, 2017

Version
nl.komponents.kovenant:kovenant:3.3.0
nl.komponents.kovenant:kovenant-android:3.3.0
Kotlin: 1.2.10
Android Studio 3.0.1
Build #AI-171.4443003, built on November 10, 2017
JRE: 1.8.0_152-release-915-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7 6.1

Test Code:

val test = mutableListOf<Promise<Int, Exception>>()
test.add(task { task { 1 }.get() })
all(test) success {
    // Never called
}

Note that Promise.of(1).get() works fine but not task { 1 }.get().

I can confirm that the inner task has been executed but somehow success is never called. I was trying to use this as fallback task, for example:

task {
    cache.get(key) ?: loadFromWebTask(key).get()
}
@friendoye
Copy link

You could try task { task { 1 } }.unwrap().

@mplatvoet
Copy link
Owner

Do you happen to have Kovenant configured with just one worker thread? Because in that case this indeed will block. It's not a good idea to use blocking methods like get in a mix with async methods. Like @friendoye suggested, you are probably want to use unwrap. Or just try to avoid nested Promises al together.

@joshuaavalon
Copy link
Author

@mplatvoet I used the default number of thread. I have rewritten the code to avoid it though.

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

3 participants