AgentStack
SKILL verified CC0-1.0 Self-run

Python Notebooks Async

skill-ahgraber-skills-python-notebooks-async · by ahgraber

|-

No reviews yet
0 installs
16 views
0.0% view→install

Install

$ agentstack add skill-ahgraber-skills-python-notebooks-async

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access Used
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Python Notebooks Async? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Python Notebooks Async

Overview

Notebook kernels own the event loop; async code must cooperate with that ownership rather than fight it. This skill covers orchestration patterns, top-level await, and compatibility constraints for .ipynb and #%% workflows.

Treat these recommendations as preferred defaults. When project constraints require deviation, call out tradeoffs and compensating controls.

When to Use

  • asyncio.run() raises RuntimeError inside a notebook cell.
  • Event-loop conflicts when mixing async libraries in Jupyter.
  • Porting async scripts into notebook workflows.
  • Orchestrating concurrent tasks (gather, TaskGroup) in IPython kernels.
  • Deciding where to place reusable async logic across notebook/module boundaries.

When NOT to Use

  • Pure script or service code with no notebook involvement — see python-concurrency-performance.
  • Synchronous notebook workflows with no async needs.
  • General asyncio API design outside notebook contexts — see python-runtime-operations.

Quick Reference

  • Treat notebook kernels as loop-owned environments; never create a competing loop.
  • Use top-level await instead of asyncio.run() in notebook cells.
  • Orchestrate concurrent work with asyncio.gather() or asyncio.TaskGroup.
  • Keep reusable async logic in regular .py modules, imported into notebooks.
  • Use nest_asyncio only as a constrained compatibility fallback, not a default.
  • Avoid fire-and-forget tasks — always await or collect results explicitly.

Common Mistakes

  • Calling asyncio.run() in a notebook cell.

The kernel already runs a loop; asyncio.run() tries to start a second one and raises RuntimeError. Use await directly instead.

  • Applying nest_asyncio globally by default.

It patches the loop to allow reentrant calls but masks design problems and can hide subtle concurrency bugs. Reserve it for legacy compatibility.

  • Defining async helpers inline in cells instead of modules.

Inline definitions are lost on kernel restart and cannot be tested outside the notebook. Extract to .py files.

  • Ignoring returned tasks or coroutines.

Calling an async function without await silently produces a never-executed coroutine object, with no error until results are missing downstream.

  • Mixing blocking I/O with async in the same cell.

Synchronous calls like requests.get() block the event loop, starving concurrent tasks. Use aiohttp, httpx, or asyncio.to_thread().

Scope Note

  • Treat these recommendations as preferred defaults for common cases, not universal rules.
  • If a default conflicts with project constraints or worsens the outcome, suggest a better-fit alternative and explain why it is better for this case.
  • When deviating, call out tradeoffs and compensating controls (tests, observability, migration, rollback).

Invocation Notice

  • Inform the user when this skill is being invoked by name: python-design-modularity.

References

  • references/notebooks-async.md

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.