Skip to content

Concurrent AsyncTranscript waits can erase an already returned terminal result #308

Open

Description

@codebanditssss

AsyncTranscript.wait_for_completion() assigns every poll response to the shared transcript object it returns. When two callers wait on the same transcript, an older in-flight poll can land after the other caller already received the terminal result, and it overwrites that result.

Reproduction

At 0ba094c, with a local HTTP server and the public API:

  1. transcript = await aai.AsyncTranscriber(client=client).submit(url)
  2. Waiter A: asyncio.create_task(transcript.wait_for_completion()). The server snapshots processing for A's GET and holds the response.
  3. Waiter B: finished = await transcript.wait_for_completion(). Its GET returns completed with text.
  4. Release A's held response.

The server state only moves forward; only response delivery is reordered.

Expected

finished.status, finished.text and finished.error stay terminal.

Actual

before=(completed, 'finished text', None)
after=(processing, None, None)

With error, the error reason becomes None. A also goes back to sleep for the polling interval even though the transcript is done. All four combinations (queued/processing then completed/error) reproduce.

Root cause: assemblyai/prerecorded/v2/async_transcript.py assigns self._transcript = await async_api.get_transcript(...) without checking whether another waiter already installed a terminal response.

Related: #282 changes the polling sleep budget, not result ownership. A fix with regression tests follows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions