{"record":{"id":"42d34ecabbb36819","repo":"unslothai/unsloth","slug":"a-video-load-is-already-in-progress","errorCode":null,"errorMessage":"A video load is already in progress.","messagePattern":"A video load is already in progress\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"studio/backend/core/inference/video.py","lineNumber":1340,"sourceCode":"        assert_video_precision_available(\n            fam,\n            model_kind = resolve_video_model_kind(gguf_filename, model_kind),\n            transformer_quant = transformer_quant,\n            text_encoder_quant = text_encoder_quant,\n            gpu_ordinal = gpu_ordinal,\n        )\n        # Resolved out here so the companion claim is published in the SAME locked section as\n        # _loading. begin_load returns as soon as the thread is scheduled, and a delete arriving in\n        # that gap sees only repo_id and base_repo, passes the guard, and starts removing a\n        # companion repo this load needs. A later claim does not revoke a delete already admitted.\n        from .video_minimax_h3 import H3_COMPONENT_REPO, H3_GGUF_REPO, is_h3_native\n\n        h3_native = is_h3_native(fam, resolve_video_model_kind(gguf_filename, model_kind))\n        claimed_assets = (H3_GGUF_REPO, H3_COMPONENT_REPO) if h3_native else ()\n\n        with self._lock:\n            if self._loading is not None and self._loading.error is None:\n                raise RuntimeError(\"A video load is already in progress.\")\n            self._load_token += 1\n            token = self._load_token\n            # A NEW event per load, never a clear() of the shared one: unload() sets the event the running worker holds but also\n            # drops _loading, so the next begin_load would clear the object that worker watches. A fresh object leaves it set.\n            cancel_event = threading.Event()\n            self._cancel_event = cancel_event\n            self._loading = _VideoLoadingState(\n                repo_id = repo_id,\n                base_repo = fam.base_repo,\n                asset_repos = claimed_assets,\n            )\n\n        threading.Thread(\n            target = self._run_load,\n            kwargs = dict(\n                repo_id = repo_id,\n                gguf_filename = gguf_filename,\n                base_repo = base_repo,","sourceCodeStart":1322,"sourceCodeEnd":1358,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/video.py#L1322-L1358","documentation":"Raised by begin_load when another video model load is already running (self._loading is set and its error is None). Video loads are heavyweight and single-slot; this RuntimeError enforces one load at a time. The state also claims companion asset repos under the same lock so a concurrent delete cannot pull a repo out from under an in-flight load.","triggerScenarios":"Calling begin_load a second time while the first load thread is still running — double-click on Load in the UI, two API clients loading concurrently, or a retry fired before the previous load finished or failed.","commonSituations":"Impatient double-clicks; a frontend not disabling the load button while loading; parallel batch scripts against the same backend; a stuck/slow download making the user re-submit.","solutions":["Wait for the in-flight load to finish (poll status) before issuing another.","Cancel or unload the current load first, then begin the new one.","Frontend: disable the Load button while the loading state is active."],"exampleFix":"# before\nbegin_load(...)  # user double-clicks -> second call raises\n\n# after\nstatus = video.status()\nif status.loading:\n    video.cancel() or wait(status)\nbegin_load(...)","handlingStrategy":"try-catch","validationCode":"with backend._lock:\n    busy = backend._loading is not None and backend._loading.error is None\nif busy:\n    wait_or_cancel()  # instead of calling begin_load again","typeGuard":null,"tryCatchPattern":"try:\n    backend.begin_load(...)\nexcept RuntimeError as e:\n    if str(e) == 'A video load is already in progress.':\n        wait_for_load_completion()  # or cancel(), then retry\n    else:\n        raise","preventionTips":["Disable the Load action while the loading state is active.","Model switches should be cancel -> wait -> load, never two begin_loads back to back.","Treat 'already in progress' as a benign condition, not a fault."],"tags":["video","concurrency","load-state","runtime"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}