add # 新增作物、种子仓库界面

This commit is contained in:
2026-10-21 17:31:45 +08:00
parent 4a484bfde6
commit dd47ab70c4
6 changed files with 371 additions and 5 deletions
+24
View File
@@ -8,6 +8,7 @@ import hashlib
from .shop import render_shop
from .details import render_details
from .warehouse import render_warehouse
logger = logging.getLogger(__name__)
@@ -116,6 +117,29 @@ class RenderService:
task.add_done_callback(finished)
return await asyncio.shield(task)
async def warehouse(self, rows, snapshot, kind, page, pages,
image_format='AUTO'):
if self._closed:
raise RuntimeError('Render service closed')
key = ('warehouse', rows, snapshot, kind, page, pages, image_format)
task = self._pending.get(key)
if task is None:
if len(self._pending) >= self._max_pending:
raise RuntimeError('Render queue full')
task = asyncio.create_task(self._run_function(
render_warehouse, self.renderer, rows, snapshot, kind,
page, pages, image_format,
))
self._pending[key] = task
def finished(done):
self._pending.pop(key, None)
if not done.cancelled():
done.exception()
task.add_done_callback(finished)
return await asyncio.shield(task)
async def _run_function(self, function, *args):
started = perf_counter()
async with self._semaphore: