Skip to content

Commit

Permalink
Limit concurrency of pds background tasks (bluesky-social#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy authored Apr 27, 2023
1 parent 384e739 commit 7d1243f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/pds/src/event-stream/background-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { dbLogger } from '../logger'
// A simple queue for in-process, out-of-band/backgrounded work

export class BackgroundQueue {
queue = new PQueue()
queue = new PQueue({ concurrency: 10 })
constructor(public db: Database) {}

add(task: Task) {
if (this.queue.isPaused) {
return
}
this.queue
.add(() => task(this.db))
.catch((err) => {
Expand Down

0 comments on commit 7d1243f

Please sign in to comment.