Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

TypeError: object async_generator can't be used in 'await' expression #1

@fortunto2

Description

@fortunto2

Python 3.12
uv pip install flash-attn --no-build-isolation (not from link)


When auto-captioning is enabled, the function start_caption_generation—which is defined as an asynchronous generator—gets awaited directly in the on_import_success function. This results in the following error:

TypeError: object async_generator can't be used in 'await' expression

Context

The error occurs because start_caption_generation uses yield to produce multiple updates and therefore returns an async generator. Directly awaiting an async generator is not allowed. Instead, the generator should either be iterated over using an async for loop or scheduled as a background task using asyncio.create_task.

This issue is observed in app.py around line 1004 in the on_import_success function.

Code Snippet

In app.py (around line 1004):

async def on_import_success(enable_splitting, enable_automatic_content_captioning, prompt_prefix):
    videos = self.list_unprocessed_videos()
    if videos and not self.splitter.is_processing() and enable_splitting:
        await self.start_scene_detection(enable_splitting)
        msg = "Starting automatic scene detection..."
    else:
        for video_file in VIDEOS_TO_SPLIT_PATH.glob("*.mp4"):
            await self.splitter.process_video(video_file, enable_splitting=False)
        msg = "Copying videos without splitting..."
    
    copy_files_to_training_dir(prompt_prefix)

    # Start auto-captioning if enabled
    if enable_automatic_content_captioning:
        await self.start_caption_generation(
            DEFAULT_CAPTIONING_BOT_INSTRUCTIONS,
            prompt_prefix
        )
    
    return {
        tabs: gr.Tabs(selected="split_tab"),
        video_list: videos,
        detect_status: msg
    }

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingupdate availableFeature of fix is pushed but needs testing

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions