Esempio n. 1
0
async def update_problem_data(session):
    logger.info('Update problem data')
    result = await session.judge_datalist(config.get('last_update_at', 0))
    for pid in result['pids']:
        await cache_invalidate(pid['domain_id'], str(pid['pid']))
        logger.debug('Invalidated %s/%s', pid['domain_id'], str(pid['pid']))
    config['last_update_at'] = result['time']
    await save_config()
Esempio n. 2
0
File: daemon.py Progetto: zema1/jd4
 async def build(self):
     self.next(status=STATUS_COMPILING)
     package, message, _, _ = await shield(build(self.lang, self.code.encode()))
     self.next(compiler_text=message)
     if not package:
         logger.debug('Compile error: %s', message)
         raise CompileError(message)
     return package
Esempio n. 3
0
 async def build(self):
     self.next(status=STATUS_COMPILING)
     package, message, time_usage_ns, memory_usage_bytes = \
         await shield(pool_build(self.lang, self.code))
     self.next(compiler_text=message)
     if not package:
         logger.debug('Compile error: %s', message)
         raise CompileError(message, time_usage_ns, memory_usage_bytes)
     return package
Esempio n. 4
0
 async def judge(self, cases_file, package):
     self.next(status=STATUS_JUDGING, progress=0)
     cases = list(read_legacy_cases(cases_file))
     total_status = 0
     total_score = 0
     total_time_usage_ns = 0
     total_memory_usage_bytes = 0
     for index, case in enumerate(cases):
         status, score, time_usage_ns, memory_usage_bytes, stderr = await case.judge(
             sandbox, package)
         self.next(status=STATUS_JUDGING,
                   case={
                       'status':
                       status,
                       'score':
                       score,
                       'time_ms':
                       time_usage_ns // 1000000,
                       'memory_kb':
                       memory_usage_bytes // 1024,
                       'judge_text':
                       stderr.decode(encoding='utf-8', errors='replace')
                   },
                   progress=(index + 1) * 100 // len(cases))
         logger.debug('Case %d: %d, %g, %g, %g, %s', index, status, score,
                      time_usage_ns / 1000000, memory_usage_bytes / 1024,
                      stderr)
         total_status = max(total_status, status)
         total_score += score
         total_time_usage_ns += time_usage_ns
         total_memory_usage_bytes = max(total_memory_usage_bytes,
                                        memory_usage_bytes)
     self.end(status=total_status,
              score=total_score,
              time_ms=total_time_usage_ns // 1000000,
              memory_kb=total_memory_usage_bytes // 1024)
     logger.info('Total: %d, %g, %g, %g', total_status, total_score,
                 total_time_usage_ns / 1000000,
                 total_memory_usage_bytes / 1024)
Esempio n. 5
0
 async def update_problem_data(self):
     domain_id = self.request.pop('domain_id')
     pid = str(self.request.pop('pid'))
     await cache_invalidate(domain_id, pid)
     logger.debug('Invalidated %s/%s', domain_id, pid)
     await update_problem_data(self.session)