kotlinx.coroutines.channels.ClosedSendChannelException: Channel was closed
at kotlinx.coroutines.channels.Closed.getSendException(AbstractChannel.kt:1107)
at kotlinx.coroutines.channels.AbstractSendChannel.helpCloseAndResumeWithSendException(AbstractChannel.kt:230)
at kotlinx.coroutines.channels.AbstractSendChannel.access$helpCloseAndResumeWithSendException(AbstractChannel.kt:19)
at kotlinx.coroutines.channels.AbstractSendChannel.sendSuspend(AbstractChannel.kt:220)
at kotlinx.coroutines.channels.AbstractSendChannel.send(AbstractChannel.kt:136)
at kotlinx.coroutines.channels.ChannelCoroutine.send(Unknown Source:2)

因为 channel在另一个flow/channel里, 而kotlin的 job与channel 都是带 group概念的, 一个顶层job/channel关闭,会导致在其中的其他 也关闭

flow/channelFlow不能用时,可以使用 callbackFlow

https://blog.csdn.net/androiddevs/article/details/116078525

channelFlow 可以在不同的 CoroutineContext 或协程之外使用 offer(trySend) 方法发送数据。但一定要在block块内添加

awaitClose { channel.close(Throwable("完成")) }

最新文章

  1. java之ubuntu12.04 开发环境配制
  2. 6-02使用SQL语句向表中插入数据
  3. .net windows 服务创建、安装、卸载和调试
  4. 存在网路的情况下重命名SDE中数据图层错误(The orphan junction feature class cannot be renamed)
  5. Web性能压力测试工具之Apache AB 详解
  6. uva 10655 - Contemplation! Algebra
  7. oracle设备
  8. java_Eclipse自动生成作者、日期注释等功能设置_导入 xml方式
  9. (笔记):组合and继承之访问限制(一)
  10. php提供的sapi有哪些?CGI、FastCGI、php-fpm、php-cgi解释
  11. (2)Deep Learning之线性单元和梯度下降
  12. 十款不容错过的Swift iOS开源项目及介绍
  13. js进度条小事例
  14. Win7 安装bundle
  15. getParameter() getInputStream()和getReader() 区别 这三种方法是有冲突的,因为流只能被读一次。
  16. Python常用字符编码
  17. poj 3683(2-SAT+SCC)
  18. LeetCode--255--用队列实现栈(java版)
  19. jupyterlab notebook区别
  20. HDOJ 1814 Peaceful Commission

热门文章

  1. 时间序列分析 2.X 单位根检验
  2. npm报错最好的办法就是删掉依赖然后重装
  3. 新的学习历程-python2 print
  4. vue指令入门
  5. 关于DIFF插件的使用
  6. nginx配置普通server
  7. Win10安装离线.NET3.5流程
  8. WPF 入门教程DispatcherTimer计时器
  9. React-Navigation 5.x 的 demo案例
  10. hdu 4283You Are the One