mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: seperate task and schedule to enhance performance (#440)
This commit is contained in:
1 parent
101fcaa1b5
commit
175609259a
19 files changed
+250
-144
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import type { JudgeResultBody } from 'hydrooj';
|
||||
import {
|
||||
SettingModel, StorageModel, SystemModel, TaskModel,
|
||||
JudgeResultBody, RecordModel, SettingModel,
|
||||
StorageModel, SystemModel, TaskModel,
|
||||
} from 'hydrooj';
|
||||
import { end, next } from 'hydrooj/src/handler/judge';
|
||||
import { processTestdata } from '../cases';
|
||||
@@ -75,7 +75,10 @@ const session = {
|
||||
|
||||
export async function postInit() {
|
||||
if (SystemModel.get('hydrojudge.disable')) return;
|
||||
const handle = (t) => (new JudgeTask(session, t)).handle().catch(logger.error);
|
||||
const handle = async (t) => {
|
||||
const rdoc = await RecordModel.get(t.domainId, t.rid);
|
||||
(new JudgeTask(session, Object.assign(rdoc, t))).handle().catch(logger.error);
|
||||
};
|
||||
TaskModel.consume({ type: 'judge' }, handle);
|
||||
TaskModel.consume({ type: 'judge', priority: { $gt: -50 } }, handle);
|
||||
}
|
||||
Reference in new issue
Block a user