https://kotlinlang.org logo
Title
w

wouterdoeland

06/04/2017, 4:17 PM
When running this
println("received update."); launch(CommonPool) { println("in pool"); //more code }
code on my desktop, it does print
received updated.
and
in pool
, but when running it on an Digital Ocean droplet it only prints
received update.
. Any reason why?
o

orangy

06/04/2017, 4:22 PM
Can it be that your main function exits before scheduled code runs? Does adding
sleep
helps?
w

wouterdoeland

06/04/2017, 4:30 PM
No, I already have infinite sleep
o

orangy

06/04/2017, 4:32 PM
That’s weird, can you test that direct use of `CompletableFuture`works?
w

wouterdoeland

06/04/2017, 4:36 PM
Where should I put that? Replace launch(CommonPool) with CompletableFuture.runAsync ?
o

orangy

06/04/2017, 4:38 PM
Yep, something like this
w

wouterdoeland

06/04/2017, 4:41 PM
It doesn't compile because a suspending function should only be called from a coroutine or other suspending function. Is there a way to ignore these errors and run a suspending function on the main thread/not in a coroutine?
I just don't get why it won't run on my server. I have openjdk8 installed in it on Ubuntu 16.04
o

orangy

06/04/2017, 5:08 PM
Well, you don’t need to put suspending function inside, just println or something. But if you have really some more complex code, you might want to check if it throws and exception is lost/ignored or something.
w

wouterdoeland

06/04/2017, 5:48 PM
How would I do that, because the first function that is being run is
println("in pool")
Even with only that function in it it doesn't print
"in pool"
e

elizarov

06/04/2017, 7:29 PM
Can you reproduce the problem with some small use-case? Does it persist without "more code" inside?