Closed
Bug 1561668
Opened 7 years ago
Closed 6 years ago
Find a simple way to serialize an async function
Categories
(Taskcluster :: Services, task)
Taskcluster
Services
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: dustin, Assigned: dustin, Mentored)
Details
In a few places, we have an async function of which we would like to run only one copy at a time:
- https://github.com/taskcluster/taskcluster/blob/d2fd03b31eb9bf106e150c1a44d286d08922b73d/services/hooks/src/listeners.js#L181
- https://github.com/taskcluster/taskcluster/pull/905/files/d11ef3519e1b6ffcd406fd3d74415d91857ce77c#diff-1d5f460c613ce4f712c189a3c9e97282R64
- https://github.com/taskcluster/taskcluster/blob/master/services/web-server/src/PulseEngine/index.js#L100
We should come up with a clear, consistent way to do this -- perhaps just by using one of the async mutex libraries out there.
| Assignee | ||
Updated•7 years ago
|
Assignee: dustin → nobody
Mentor: dustin
| Assignee | ||
Updated•6 years ago
|
Assignee: nobody → dustin
| Assignee | ||
Comment 1•6 years ago
|
||
It looks like https://github.com/sindresorhus/p-limit is the tool for this. And we already require it indirectly!
=> Found "p-limit@2.2.1"
info Reasons this module exists
- "_project_#find-up#locate-path#p-locate" depends on it
- Hoisted from "_project_#find-up#locate-path#p-locate#p-limit"
- Hoisted from "_project_#c8#find-up#locate-path#p-locate#p-limit"
- Hoisted from "_project_#c8#yargs#find-up#locate-path#p-locate#p-limit"
| Assignee | ||
Comment 2•6 years ago
|
||
Hm, but that doesn't let you wait until all pending calls are complete.
| Assignee | ||
Comment 3•6 years ago
|
||
I wrote https://github.com/djmitche/p-sync - let's see what sindresorhus thinks.
| Assignee | ||
Comment 4•6 years ago
|
||
| Assignee | ||
Updated•6 years ago
|
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•