Skip to content

Unstarted lazy job prevents parent from completion #1545

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

Open
cy6erGn0m opened this issue Sep 17, 2019 · 2 comments
Open

Unstarted lazy job prevents parent from completion #1545

cy6erGn0m opened this issue Sep 17, 2019 · 2 comments

Comments

@cy6erGn0m
Copy link
Contributor

The following example hangs forever:

class LazyChildTest : CoroutineScope {
    @get:Rule
    val timeout: CoroutinesTimeout = CoroutinesTimeout.seconds(1)

    private val parent = Job()
    override val coroutineContext: CoroutineContext = parent

    @BeforeTest
    fun start() {
        launch(CoroutineName("lazy-job"), start = CoroutineStart.LAZY) {
        }
    }

    @AfterTest
    fun cleanup() {
        parent.cancel()
    }

    @Test
    fun test(): Unit = runBlocking(CoroutineName("blocking")) {
        parent.complete()
        parent.join()
    }
}

The reason is that the lazy job didn't start so the parent will never complete. The first idea is to force a recursive children startup at parent completion.

@cy6erGn0m
Copy link
Contributor Author

Also, remember about #1544 as well since they are connected.

@fvasco
Copy link
Contributor

fvasco commented Sep 17, 2019

See: Customizable coroutine behaviour on scope termination #1065

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

No branches or pull requests

3 participants