-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat: workerId #30
feat: workerId #30
Conversation
@sheremet-va couldn't put you in the reviewers! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also lockfile is kind of big for this changes, don't you think? 👀
src/index.ts
Outdated
@@ -807,7 +836,7 @@ class ThreadPool { | |||
taskInfo.workerInfo.taskInfos.delete(taskInfo.taskId) | |||
if (!taskInfo.workerInfo.taskInfos.size) { | |||
this._removeWorker(taskInfo.workerInfo) | |||
this._ensureMaximumWorkers() | |||
// this._ensureMaximumWorkers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure about this? 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should not spawn workers, we should let the scheduler figures it out!
export * from './common' | ||
export { Tinypool, Options } | ||
export { Tinypool, Options, _workerId as workerId } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the only way I can get worker id is by importing tinypool
inside a script that is running in a worker? Like this:
import { workerId } from 'tinypool'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or accessing process.__tinypool_state__?.workerId
Also some tests are failing |
Maybe we also need to remove v17 and add v18 for ci tests |
This PR tries to solve this vitest issue where pool id can be greater than
maxThreads
! Therefore I'm implementing theworkerId
which would be generated for each worker and will not be greater thanmaxThreads
It can be imported from
tinypool
asworkerId
in the worker when running!