runtime: failed to create new OS thread
KrullBorg opened this issue · 4 comments
i'm trying the simple sample test to generate the pdf file
but i only get the error "runtime: failed to create new OS thread" and "fatal error: newosproc" after a lot of "exit status 1"
i think the problem is that the wkhtmltopdf on my ditro needs to run only under X (i usually use xvfb-run); but i'm not sure, because i made a simple wrap file, named wkhtmltopdf, on current dir that runs "xvfb-run wkhtmltopdf"... i also setted WKHTMLTOPDF_PATH=. to be sure that go-wkhtmltopdf use the wrapper... but same errors
what am I doing wrong?
thanks in advance
UPDATE: solved
yes the problem is the wkhtmltopdf version that needs X
i don't know why but putting the wrapper in current dir or setting WKHTMLTOPDF_PATH didn't work; i solved using the function SetPath
thanks again
Thanks for the details.
On the PATH issue, SetPath forces it (it just sets the path you specify) while WKHTMLTOPDF_PATH looks if it can find an executable at the location specified (using exec.LookPath)
If you specified it relative to your current directory and are using Go 1.19 is might also have to do with a recent change in Go, see section PATH lookups
on https://go.dev/doc/go1.19
Hello, Sebastiaan! Thank you for such a convenient library. I have one question, I just didn't want to open another issue and couldn't find any contact information.
if I should process multiple requests for document creation I run several goroutines. Each goroutine tries to create its own document and starts new OS process. If so, speed of creation for one document increases dramatically. Is there an option to optimize it for generating multiple PDFs at the same time? Thank you!
Hi @RaiymbekValikhanov I don't think this is something I can help with. In my Go wrapper you can just create a new PDFGenerator
object in each goroutine, but the performance seems to be limited by wkhtmltopdf itself which is not really handling multi threading very well.
Are you using X as well? https://stackoverflow.com/questions/28212965/wkhtmltopdf-not-handling-multiple-request-at-a-time-through-threads
If not, there are some limitations to multi threading, you can start with https://github.com/wkhtmltopdf/wkhtmltopdf/issues but it will depend on your OS how performant it is, but I don't know the exact limitations, it i usually screen buffer related because it is actually rendering the pages.
I don't have a whole lot of experience in this field because we run it in AWS Lambda so it just scales horizontally.
You could also look at alternatives like https://github.com/arachnys/athenapdf