Comment

Comment by scribu

> But isn't it true for JavaScript too?

You're right, the equivalent JS script produces the same sequence of outputs.

It turns out there is a way to emulate Python's asyncio.create_task().

Python:

  await asyncio.create_task(child())
JavaScript:

  const childTask = new Promise((resolve) => {
    setTimeout(() => child().then(resolve), 0)
  })
  await childTask
parent scribu 11 months ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton