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

elizarov

06/03/2017, 8:51 AM
@wouterdoeland: can you elaborate please? Does not it work or what?
w

wouterdoeland

06/03/2017, 8:54 AM
elizarov: I got an expection about there not being a transaction or something. Unfortunately I have already removed the code and switched to handwritten SQL statements so I don't have the code anymore. But basically, I got an exception when trying to call User.find in a coroutine (
launch(CommonPool)
and in ktor)
e

elizarov

06/03/2017, 8:55 AM
Can you reproduce it with some selfcontained code and share it?
w

wouterdoeland

06/03/2017, 9:03 AM
Wait a minute... Do your transactions have to be in a transaction block? If so then sorry, my fault.
o

orangy

06/03/2017, 12:36 PM
Try #exposed to talk to devs, but I suspect it is not coroutines-ready, because it stores transactions in Thread Local, and coroutine continuation can be scheduled to any thread on a pool. What’s worse, even if you constrain dispatcher to only dispatch on the same thread, several coroutines can be running on a same thread, so their transactions could be messed up. You might need a special coroutine-enabled TransactionManager in Exposed.
If you wish to do something on a cutting edge, you might try
squash
, it doesn’t store transaction in a thread local, but instead relies on lambda closures to have it handy. But it’s not coroutine-first (like ktor) still, so some work might be done. I have it on the radar to make an async coroutine-first SQL lib, but don’t have quite enough time right now.
8 Views