-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support stdout and stderr on the worker #137
Comments
@addaleax would likely be able to explain what's happening here a lot better than I can since she wrote that part of the workers code... generally tho... process.stdout and process.stderr in workers essentially forward the data on to main thread for processing. What would appear to be happening here is that the write callbacks might not be getting called. |
my guess would be that if it's not closing the thread it has something to do with needing to close at least stdin, maybe both, when it's time to shut down the thread. |
Have you tried setting |
This issue has been marked as stale because it has been opened 30 days without activity. Remove stale label or comment or this will be closed in 5 days. |
@logikaljay is this still valid? |
@metcoder95 no its all good, closing. |
I want to stream the stdout and stderr of the tasks to a log file/database/websocket etc.
I think it is achievable, providing a change is made to the options provided to the
Worker
constructor here:piscina/src/index.ts
Lines 570 to 577 in 2f95678
I implemented this locally and it seemed to work.. mostly.. (happy to open a PR).
The issue I found was that the task never ended.. I couldn't figure this out, it may have been my stream.. I used
fs.createWriteStream
to see if it would create a log file of the tasks stdout, which it did.However as I described, when the task finished, the application did not exit as it does when
stdout
is set tofalse
on theWorker
.There is probably something I am missing, especially when it comes to the
stdout
andstderr
checks being made here:piscina/src/worker.ts
Lines 158 to 167 in 2f95678
There were also some warnings in the console about a "Possible EventEmitter memory leak" being detected:
I believe this is because I am adding the same listener to each worker. setting setMaxListeners higher than the number of CPU cores resolved this warning - this is probably not the correct way to go about this though.
Any thoughts/comments would be appreciated. Hopefully I am not wasting anyones time.
The text was updated successfully, but these errors were encountered: