mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 23:50:08 +08:00
Add timeout for logout on close
This commit is contained in:
parent
6d0e5adf95
commit
753342d99e
@ -52,6 +52,7 @@ import net.mamoe.mirai.utils.BotConfiguration
|
||||
import net.mamoe.mirai.utils.MiraiLogger
|
||||
import net.mamoe.mirai.utils.lateinitMutableProperty
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
internal fun Bot.asQQAndroidBot(): QQAndroidBot {
|
||||
contract {
|
||||
@ -73,7 +74,9 @@ internal open class QQAndroidBot constructor(
|
||||
if (!this.isActive) return
|
||||
runBlocking {
|
||||
try { // this may not be very good but
|
||||
components[SsoProcessor].logout(network)
|
||||
withTimeoutOrNull(5.seconds) {
|
||||
components[SsoProcessor].logout(network)
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user