I couldn't find any example of this so I thought I would share one I put together. It's a mind dump of code used in production, although this particular bit is untested, it shows the idea. I used it for a PDF generation pool (Launching new chromium instances on every request was making the server run out of memory)