https://kotlinlang.org logo
#coroutines
Title
# coroutines
y

yschimke

02/24/2019, 10:19 AM
Is there a clear pattern for launching true background work? Does supervisorScope instead of coroutineScope allow the work to continue in the background, while coroutineScope returns sooner?
Actually I guess it's just GlobalScope
r

radityagumay

02/24/2019, 12:28 PM
@yschimke “The reason to avoid GlobalScope” by Roman Elizarov https://link.medium.com/WdakIStizU
s

Stefan Peterson

02/24/2019, 6:48 PM
I’m somewhat curious how to do this as well. I am using Kotlin server side and have a couple of Spring controllers that boot at application launch and then stick around forever. Wanted some of them to be able to spin off large batch updates asynchronously. Had my controller class extending CoroutineScope. Ran into an issue with exceptions being thrown inside a launch {} and I think what I needed to do was declare an exception handler in order to not cause that to brick my scope.
b

bdawg.io

02/24/2019, 7:06 PM
You can still have your own "ApplicationScope" that has a lifecycle managed by your application instead of GlobalScope that's managed by the lifecycle of the runtime (ie, JVM)
e

elizarov

02/25/2019, 7:01 AM
forever == while JVM is alive ==
GlobalScope
r

radityagumay

12/22/2019, 8:28 AM
@elizarov thank you for explicit point
3 Views