mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02: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) {
|
for (const a of albums) {
|
||||||
await AlbumManager.updateAlbum(a as SavedSearchEntity);
|
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;
|
this.isDBValid = true;
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,9 @@ export abstract class Job<T = void> implements IJob<T> {
|
|||||||
this.onFinish();
|
this.onFinish();
|
||||||
return;
|
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();
|
this.run();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logger.error(LOG_TAG, e);
|
Logger.error(LOG_TAG, e);
|
||||||
|
Loading…
Reference in New Issue
Block a user