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?
+1
A:
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
oxbow_lakes
2009-11-17 14:56:33
This doesn't work for me (using 2.7.7)
IttayD
2009-11-18 08:16:20
What exactly are you doing? Admittedly I'm not using specs but I'm having no issues with actor thread-pool threads not terminating
oxbow_lakes
2009-11-18 09:13:33