mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&judge: ignore deleted tasks
This commit is contained in:
2 files changed
+9
-3
No files matched your search
@@ -76,6 +76,10 @@ export async function postInit() {
|
|||||||
await fs.ensureDir(getConfig('tmp_dir'));
|
await fs.ensureDir(getConfig('tmp_dir'));
|
||||||
const handle = async (t) => {
|
const handle = async (t) => {
|
||||||
const rdoc = await RecordModel.get(t.domainId, t.rid);
|
const rdoc = await RecordModel.get(t.domainId, t.rid);
|
||||||
|
if (!rdoc) {
|
||||||
|
logger.debug('Record not found: %o', t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
(new JudgeTask(session, Object.assign(rdoc, t))).handle().catch(logger.error);
|
(new JudgeTask(session, Object.assign(rdoc, t))).handle().catch(logger.error);
|
||||||
};
|
};
|
||||||
TaskModel.consume({ type: 'judge' }, handle);
|
TaskModel.consume({ type: 'judge' }, handle);
|
||||||
|
|||||||
@@ -195,14 +195,16 @@ class JudgeConnectionHandler extends ConnectionHandler {
|
|||||||
async newTask() {
|
async newTask() {
|
||||||
if (this.processing) return;
|
if (this.processing) return;
|
||||||
let t;
|
let t;
|
||||||
|
let rdoc: RecordDoc;
|
||||||
while (!t) {
|
while (!t) {
|
||||||
if (this.closed) return;
|
if (this.closed) return;
|
||||||
// eslint-disable-next-line no-await-in-loop
|
/* eslint-disable no-await-in-loop */
|
||||||
t = await task.getFirst(this.query);
|
t = await task.getFirst(this.query);
|
||||||
// eslint-disable-next-line no-await-in-loop
|
|
||||||
if (!t) await sleep(500);
|
if (!t) await sleep(500);
|
||||||
|
else rdoc = await record.get(t.domainId, t.rid);
|
||||||
|
/* eslint-enable no-await-in-loop */
|
||||||
|
if (!rdoc) t = null;
|
||||||
}
|
}
|
||||||
let rdoc = await record.get(t.domainId, t.rid);
|
|
||||||
this.send({ task: { ...rdoc, ...t } });
|
this.send({ task: { ...rdoc, ...t } });
|
||||||
this.processing = t;
|
this.processing = t;
|
||||||
const $set = { status: builtin.STATUS.STATUS_FETCHED };
|
const $set = { status: builtin.STATUS.STATUS_FETCHED };
|
||||||
|
|||||||
Reference in new issue
Block a user