• 14

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I'm trying to execute a suspendable function from a lambda expression:

fun executeAll() {
     // non-ui thread required for this task. Retain the jobId and clear it once the VM is destroyed
     jobId = launch(Dispatchers.IO) {
         try {
             // execute all queries in one transaction
             appDatabase.runInTransaction {
                 // !! THIS --> "Suspension functions can be called only with coroutine body"
         catch (e: Exception) {

 private suspend fun runQueries() {

 override fun onCleared() {

Executing the runQueries() gives me an error, because it's not called from a coroutine body. But how can I fix this? I'm already calling a launch(Dispatchers.IO). Should I create a new coroutine job? What have I done is I wrapped inside a runBlocking block:

runBlocking {

But I've read that I shouldn't use runBlocking in production, because it was a mistake by the Kotlin team and it was too late to remove it.