Skip to content
Skills Library
Programming · Building & coding

python-notebooks-async

/python-notebooks-async

Use when writing or reviewing asyncio code in Jupyter notebooks or '#%%' cell workflows — structuring event-loop ownership, orchestrating async tasks, or choosing compatibility strategies. Also use when hitting RuntimeError: This event loop is already running, asyncio.run() failures in cells, or tasks silently never completing.

Repository
skills ↗
Licence
CC0-1.0
Last repository change
20.10.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 20.10.2026, without references to retired models or APIs.

Licence

CC0-1.0, otwarta.

What it does and when to use it

Use when writing or reviewing asyncio code in Jupyter notebooks or '#%%' cell workflows — structuring event-loop ownership, orchestrating async tasks, or choosing compatibility strategies. Also use when hitting RuntimeError: This event loop is already running, asyncio.run() failures in cells, or tasks silently never completing.

Triggers from the description

#%%
Original author description

Use when writing or reviewing asyncio code in Jupyter notebooks or '#%%' cell workflows — structuring event-loop ownership, orchestrating async tasks, or choosing compatibility strategies. Also use when hitting RuntimeError: This event loop is already running, asyncio.run() failures in cells, or tasks silently never completing.

How it works

  1. Overview
  2. When to Use
  3. Invocation Notice
  4. Quick Reference
  5. Common Mistakes
  6. References
Original SKILL.md headings · 61 lines, 421 words
SKILL.md preview
---
name: python-notebooks-async
description: |-
  Use when writing or reviewing asyncio code in Jupyter notebooks or '#%%' cell workflows — structuring event-loop ownership, orchestrating async tasks, or choosing compatibility strategies. Also use when hitting RuntimeError: This event loop is already running, asyncio.run() failures in cells, or tasks silently never completing.
---

# 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.
- Synchronous notebook workflows with no async needs.
- General asyncio API design outside notebook contexts — the `python` skill covers concurrency audit defaults.

## Invocation Notice

- Tell the user when this skill is running: `python-notebooks-async`.
  Skip the notice when the user asked for the skill by name or slash command; spelling and spacing need not match.
  A phrase from this skill's own trigger list is not a name — naming the work is not naming the skill.

## 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()`.

## References

- `references/notebooks-async.md` — event-loop ownership, background-work and fire-and-forget patterns, script/notebook compatibility, blocking-library interop, `nest_asyncio` policy
Files in this package (2)
  • SKILL.md 3 KB
  • references/notebooks-async.md 4 KB

Versions

The database has no other skills named python-notebooks-async.

Database snapshot: 13.11.2026 · package version e494f5f429d6 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90python-asyncio
    Decide whether asyncio pays off, keep the event loop unblocked, and structure concurrency with TaskGroup and disciplined cancellation. Use when writing async Python or diagnosing a hung, slow, or silently-failing event loop.
  • 100interactive-notebook-demo
    Use when authoring or reviewing a hands-on demo, tour, or walkthrough notebook (`#%%` percent-format or Jupyter) that demonstrates a feature, library, or API and doubles as semi-interactive documentation. Triggers: "write a demo notebook", "build a feature demo", "demo this…
  • 100async-python-patterns
    Structure asyncio code: task management, cancellation, rate limiting, blocking calls kept off the event loop. TRIGGER WHEN: building async APIs, concurrent or I/O-bound systems needing non-blocking operations, or choosing between asyncio, threading and multiprocessing.
  • 100async-python-patterns
    Structure asyncio code: task management, cancellation, rate limiting, blocking calls kept off the event loop. TRIGGER WHEN: building async APIs, concurrent or I/O-bound systems needing non-blocking operations, or choosing between asyncio, threading and multiprocessing.
  • 100python-asyncio-pitfalls
    Use when debugging asyncio event-loop hangs, blocking calls inside coroutines, asyncio.gather vs TaskGroup choice, cancellation handling, structured concurrency, mixing sync and async, run_in_executor decisions, asyncio task lifetimes, "Task was destroyed but it is pending"…
  • 95asyncio
    asyncio patterns, concurrency pitfalls, and backpressure. Use when writing async Python services.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.