On Wed, Sep 22, 2010 at 2:31 PM, Tim Uckun <timuckun / gmail.com> wrote:
> I am running a batch process which uses the wkhtmltoimage-i386 binary
> to make screenshots of urls.  ¨Βξζοςτυξατεμω τθισ ισ ιξ βετα αξιτ
> frequently hangs up and takes up 100% of one of the CPUs on the
> machine.
>
> I have the following code to try and detect the hung process and kill
> it but it doesn't always work and I was wondering if anybody has a
> better idea of how to do this.  ¨Βθεςυιτ βω τεστιξσινπμε
> commands like sleep it works perfectly. In production with this binary
> it doesn't seem to always work.

What do you mean by that?  Goes the timeout undetected?  Can't you
kill the process?  Are there any unexpected error messages /
exceptions?

> def Util.shell_with_timeout(cmd, seconds = 3600)
> the default timeout is an hour. That's probably way too long
>
>  ¨ΒινεουτΊΊτινεουτ¨σεγοξδσ© >  ¨Βπιδ¬ ΐστδιξΐστδουτ¬ ΐστδεςΟπεξ΄®ποπεγνδ>  ¨ΒηξοςεδΐστατυΠςογεσσΊΊχαιτπιδΐπιδ
>  ¨Βΐστατυσ®εψιτστατυσ ΅½ >  ¨Βαισε ΆΕψιΣτατυσ ξοϊεςο>  ¨Βξδ
>  ¨Β
>
>  ¨Βστδουτ ΐστδουτ®ςεαδ®στςιπ §§
>  ¨ΒεσγυΤινεουτΊΊΕςςος
>  ¨Βςογεσσ®δεταγΐπιδ
>  ¨Βςογεσσ®λιμ§ΣΙΗΛΙΜΜ§¬ ΐπιδ
>  ¨Βαισε ΆΠςογεσσ ΤινεουτΆ
>  ¨Βεσγυ½Ύ >  ¨Βση  ¨Βστδεςς  ¨Βστδεςς®ςεαδ®στςι§§
>  ¨Βση «½ ε®τοίσ
>  ¨Βαισε ΆΕςςος δυςιξη εψεγυτιοοζ γονναξ£ϋγνδύάξ £ϋνσηύ>  ¨Βξδ

A frequent problem with #popen methods is to not read file descriptors
which can make the client hang (i.e. if it writes more than fits into
a pipe).  That could be something to check since you are not reading
any of the streams.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/