Почему не завершается приложение (console+kotlin coroutines+retrofit)?
import com.google.gson.annotations.SerializedName
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET
import retrofit2.http.Path
data class Place (
@SerializedName("place name")
val place_name: String,
val longitude: String,
val state: String,
@SerializedName("state abbreviation")
val state_abbreviation: String,
val latitude: String
)
data class ZipCode(
@SerializedName("post code")
val post_code: String,
val country: String,
@SerializedName("country abbreviation")
val country_abbreviation: String,
val places: Array<Place>
)
interface GameApiService {
@GET("{country}/{code}")
suspend fun getGames(@Path("country") country: String, @Path("code") code: Int): Response<ZipCode>
}
suspend fun main(): Unit = runBlocking {
val retrofit = Retrofit.Builder()
.baseUrl("https://api.zippopotam.us/")
.addConverterFactory(GsonConverterFactory.create())
.build()
val jokeApiService = retrofit.create(GameApiService::class.java)
val job: Deferred<Response<ZipCode>> = async(Dispatchers.IO) {
jokeApiService.getGames("ru", 140100)
}
val zipcode = job.await()
if (zipcode.isSuccessful)
println(zipcode.body())
//exitProcess(0)
}