File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
services/storage/src/simcore_service_storage/api/_worker_tasks Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ import asyncio
2+ import logging
3+
4+ from celery import Task # type: ignore[import-untyped]
5+ from models_library .progress_bar import ProgressReport
6+ from models_library .projects_nodes_io import StorageFileID
7+ from servicelib .logging_utils import log_context
8+
9+ from ...modules .celery .utils import get_celery_worker
10+
11+ _logger = logging .getLogger (__name__ )
12+
13+
14+ async def export_data (task : Task , files : list [StorageFileID ]):
15+ await get_celery_worker (task .app ).set_task_progress (
16+ task , ProgressReport (actual_value = 0.1 )
17+ )
18+
19+ _logger .info ("Exporting files: %s" , files )
20+ for n , file in enumerate (files , start = 1 ):
21+ with log_context (
22+ _logger ,
23+ logging .INFO ,
24+ msg = f"Exporting { file = } ({ n } /{ len (files )} )" ,
25+ ):
26+ assert task .name
27+ await get_celery_worker (task .app ).set_task_progress (
28+ task , ProgressReport (actual_value = n / len (files ) * 100 )
29+ )
30+ await asyncio .sleep (10 )
31+ return "done"
You can’t perform that action at this time.
0 commit comments