Then you have to do the input blocking in something else than an actor, and
send the input as messages to the actors.
/Patrik


On Thu, Jun 12, 2014 at 12:29 PM, Matthew Pocock <
[email protected]> wrote:

> Hi,
>
> I've got an application that uses akka. One bit of it listens to stdin and
> on a newline terminates an actor. This has a knock-on effect of closing
> down the entire system. The line is the return value of a future, and is:
>
> io.Source.*stdin*.getLines().take(1).foreach(_ => minion ! StopMinioning)
>
>
> The execution context here is the one provided by the Akka system. The
> problem is that this future sits in a blocking state even after the akka
> system (and presumably associated thread pools) have shut down. It gets
> stuck here:
>
> "MySystem-akka.actor.default-dispatcher-6" #16 prio=5 os_prio=0
> tid=0x00007f81c0004000 nid=0x536b runnable [0x00007f821b9fb000]
>    java.lang.Thread.State: RUNNABLE
> at java.io.FileInputStream.readBytes(Native Method)
>  at java.io.FileInputStream.read(FileInputStream.java:234)
> at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
>  at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
> - locked <0x0000000706a1b560> (a java.io.BufferedInputStream)
>  at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
> at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
>  at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
> - locked <0x0000000706a1c610> (a java.io.InputStreamReader)
>  at java.io.InputStreamReader.read(InputStreamReader.java:184)
> at java.io.BufferedReader.fill(BufferedReader.java:161)
>  at java.io.BufferedReader.readLine(BufferedReader.java:324)
> - locked <0x0000000706a1c610> (a java.io.InputStreamReader)
>  at java.io.BufferedReader.readLine(BufferedReader.java:389)
> at
> scala.io.BufferedSource$BufferedLineIterator.hasNext(BufferedSource.scala:67)
>  at scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:308)
> at scala.collection.Iterator$class.foreach(Iterator.scala:727)
>  at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
>
> It looks like whatever job system.shutdown does, it doesn't do enough to
> notify this IO-blocked thread. system.awaitTermination() is returning so
> akka thinks it has shut down.
>
> Is there a way to address this? I really need to be able to both read
> lines from stdin and also guarantee that the system shuts down gracefully.
> It may be running in a managed environment were I can't leak threads and
> can't call System.exit().
>
> Thanks,
> Matthew
>
> --
> Dr Matthew Pocock
> Turing ate my hamster LTD
> mailto: [email protected]
>
> Integrative Bioinformatics Group, School of Computing Science, Newcastle
> University
> mailto: [email protected]
>
> gchat: [email protected]
> msn: [email protected]
> irc.freenode.net: drdozer
> skype: matthew.pocock
> tel: (0191) 2566550
> mob: +447535664143
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

<http://www.scaladays.org/>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to