测试 Actor 时,Scala 规范不会退出

发布于 2024-08-11 15:53:52 字数 109 浏览 5 评论 0原文

我正在尝试使用 scala 规范测试一些演员。我在 IDEA 或 Maven(作为 junit)中运行测试,但它没有退出。查看代码,我的测试已完成,但一些内部线程(调度程序)仍在徘徊。我怎样才能完成测试?

I'm trying to test some actors using scala specs. I run the test in IDEA or Maven (as junit) and it does not exit. Looking at the code, my test finished, but some internal threads (scheduler) are hanging around. How can I make the test finish?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潜移默化 2024-08-18 15:53:52

目前,这只能通过强制关闭 Actor 框架的调度程序来实现:

scala.actors.Scheduler.impl.shutdown

但是,调度程序的底层实现最近在补丁版本中发生了变化,因此这可能会有所不同,或者与您所在的版本不太兼容。在2.7.7中,默认调度程序似乎是scala.actors.FJTaskScheduler2的一个实例,这种方法应该适用,但是如果您最终得到一个SingleThreadedScheduler 它不会,因为 shutdown 方法是无操作

只有当你的参与者当时没有等待 react 时,这才会起作用

Currently this is only possible by causing the actor framework's scheduler to forcibly shut down:

scala.actors.Scheduler.impl.shutdown

However, the underlying implementation of the scheduler has been changing in patch-releases lately, so this may be different, or not quite work with the version you are on. In 2.7.7 the default scheduler appears to be an instance of scala.actors.FJTaskScheduler2 for which this approach should work, however if you end up with a SingleThreadedScheduler it will not, as the shutdown method is a no-op

This will only work if your actors are not waiting on a react at that time

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文