Note that there are some explanatory texts on larger screens.

plurals
  1. POProcess.spawn hanging
    text
    copied!<p>I'm using <a href="https://github.com/celluloid/celluloid" rel="nofollow">Celluloid</a> to create a job processing server. I have a <a href="https://github.com/celluloid/celluloid/wiki/Pools" rel="nofollow">pool</a> of workers that take a task from a beanstalkd queue and process it by using <code>Process.spawn</code> to call a PHP script that does a bunch of work.</p> <p>Here's how I'm executing the PHP command:</p> <pre><code>rout, wout = ::IO.pipe pid = Process.spawn(cmd, :err=&gt; :out, :out =&gt; wout) _, exit_status = Process.wait2(pid) wout.close output = rout.readlines.join("\n") </code></pre> <p>This works "most" of the time. I've done tests with hundreds of jobs and everything processes fine. But when I put it into production, <em>some</em> PHP commands are hanging indefinitely.</p> <p>If I kill the hung processes and look at the logfile that the PHP command writes, the last log message is any number of seemingly random inconspicuous events (that is, I can't discern any pattern in how far the process gets before it hangs).</p> <p>The PHP scripts to process jobs have been used in production for months but executed on cron. So the only thing that has changed is that they're being executed from this new job processor instead.</p> <p>Am I approaching this the wrong way? Is Ruby somehow pausing/sleeping the process or something like that-- am I not reading the output properly and that is blocking it?</p> <p><strong>--- Edit ---</strong></p> <p>I switched to using the backtick operator to execute the command (blocking doesn't really matter since the Celluloid Actor is async):</p> <pre><code>output = `#{cmd}` pid = $?.pid exit_status = $?.exitstatus </code></pre> <p>And so far this is working without issue. How is using the backticks different?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload