mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Making jobs and particularly preview filling job non-blocking
This commit is contained in:
parent
534f7187c4
commit
d209816619
@ -106,6 +106,9 @@ export class AlbumManager implements IAlbumManager {
|
||||
|
||||
for (const a of albums) {
|
||||
await AlbumManager.updateAlbum(a as SavedSearchEntity);
|
||||
// giving back the control to the main event loop (Macrotask queue)
|
||||
// https://blog.insiderattack.net/promises-next-ticks-and-immediates-nodejs-event-loop-part-3-9226cbe7a6aa
|
||||
await new Promise(setImmediate);
|
||||
}
|
||||
this.isDBValid = true;
|
||||
}
|
||||
|
@ -144,6 +144,9 @@ export abstract class Job<T = void> implements IJob<T> {
|
||||
this.onFinish();
|
||||
return;
|
||||
}
|
||||
// giving back the control to the main event loop (Macrotask queue)
|
||||
// https://blog.insiderattack.net/promises-next-ticks-and-immediates-nodejs-event-loop-part-3-9226cbe7a6aa
|
||||
await new Promise(setImmediate);
|
||||
this.run();
|
||||
} catch (e) {
|
||||
Logger.error(LOG_TAG, e);
|
||||
|
Loading…
Reference in New Issue
Block a user