mathspp
  • Blog
    • Pydon'ts
    • Problems
    • TIL
    • Twitter threads
  • Books
  • Talks
  • Trainings
    • Advanced iteration
    • Python for scripting and automation
    • Rust for Python developers
  • Courses
  • About
Link blog

TIL: Every Jupyter notebook cell runs in an async loop

by Daniel Roy Greenfeld on 02-02-2025 13:47

In this TIL article Daniel shares how he learned that if you're writing asynchronous code, you don't need to run an async loop inside the notebook. In fact, you can just paste the snippet below into a code cell and it will run directly:

import asyncio

async def f():
    print("starting")
    await asyncio.sleep(3)
    print("done")

await f()

In a regular Python script, you can't write await f() just like that, outside of an asynchronous function.

Previous link Next link

The only way to learn mathematics is to do mathematics.

mathspp
  • Blog
    • Pydon'ts
    • Problems
    • TIL
    • Twitter threads
  • Books
  • Talks
  • Trainings
    • Advanced iteration
    • Python for scripting and automation
    • Rust for Python developers
  • Courses
  • About