02/28/2019, 7:46 AM
@elizarov is there a reason Job doesn't expose parentJob : Job?. My use case would be logging/debugging aids - wanting to log the path of jobs to the root when one fails, a job trace vs a stack trace. Ive managed to hack around it with this evil code but I wondering if there a strong reason for concealing
fun Job.getParent() : Job? {
    return ( as Class<*>)?.
        also { it.isAccessible = true }?.
        let { it.get(this) as? CoroutineContext? }?.
        let { it[Job] }


02/28/2019, 8:45 AM
Two reasons. One is encapsulation. Parent is Job’s internal detail. If I gave you reference to my child job, then you should be able to cancel it, but not walk up to its parent (me) and cancel me. The other one is we are looking to potentially “late binding” to a parent in the future, which makers “parent” property mutable and thus harder to reason to about.
👍 1
For debugging, I’d suggest to take a look here: We are considerably enhancing these debugging facilities for an upcoming release.


02/28/2019, 8:46 AM
Okay thanks, will take a read