n1k0/casperjs — pull request #811 by robcolburn (2014-01-27 20:59:53+00:00)
Title: Feature Request: PhantomJS Thread Support

It's a known issue that CasperJS does not support threads, but I'd really like to see a little more thread support. In particular, I'd like to be able to restart a PhantomJS thread.

If I don't include the thread killing logic on lines 54-58, then CasperJS crashes repeating the error `select: Invalid argument` after 500MB of memory or so. If I do include the logic, then CasperJS will crash as soon as I attempt to kill a thread. My other option here, is to manage Phantom pooling and threads through node, but so far I've difficulty getting the node/phantom layer to communicate properly.

Note: My example uses several npm modules. These could easily be replaced by a few plain JS functions, but they keep it easier to read.
https://npmjs.org/package/generic-pool
https://npmjs.org/package/async
https://npmjs.org/package/lodash