@pipedog/asyncio
Tasks, cooperative cancellation, timeouts, queues and events with Python asyncio semantics.
import { createTask, Event, Queue, sleep, Task, waitFor } from "@pipedog/asyncio";See Interruptions & cancellation for how cancellation points work.
Task
A unit of concurrent work, like asyncio.Task. Created with createTask(). Awaiting a task (it
is thenable) is a cancellation point, and cancelling the awaiting task also cancels the awaited
one. Only await links the two: task.then(cb), task.promise and addDoneCallback observe the
task without suspending the caller, so cancelling the caller cancels the caller alone.
Prop
Type
Task functions
Prop
Type
Timeouts and composition
Prop
Type
waitFor(aw, timeout) takes an Awaitable: pass a function so it runs as a child task that
is cancelled on timeout, raising TimeoutError. timeout is in seconds; null waits forever.
Queue
asyncio.Queue. LifoQueue and PriorityQueue subclass it by overriding the storage hooks.
get() and put() are cancellation points.
Prop
Type
Event
asyncio.Event. wait() is a cancellation point.
Prop
Type
Lock and Semaphore
async with lock: is await lock.run(async () => { ... }).
Prop
Type
Prop
Type
Errors
| Class | Python |
|---|---|
CancelledError | asyncio.CancelledError |
TimeoutError | asyncio.TimeoutError / TimeoutError |
InvalidStateError | asyncio.InvalidStateError |
QueueEmpty, QueueFull, QueueShutDown | asyncio.QueueEmpty, QueueFull, QueueShutDown |
pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.
Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).