Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was using `async` as shorthand for "whatever it takes in a particular async implementation to launch an asynchronous task". Here's an example that more or less mirrors what I showed there:

  async def main():
      task1 = asyncio.create_task(
          say_after(1, 'hello'))

      task2 = asyncio.create_task(
          say_after(2, 'world'))

      print(f"started at {time.strftime('%X')}")

      # Wait until both tasks are completed (should take
      # around 2 seconds.)
      await task1
      await task2

      print(f"finished at {time.strftime('%X')}")
https://docs.python.org/3/library/asyncio-task.html

It was a response to a particular thing you said, but I didn't quote because I thought it was obvious (my bad):

> With virtual threads, you need to write fork/join code to do two subtasks. With async await, you call two async functions and await them.

fork/join and async(for you: "whatever it takes in a particular async implementation to launch an asynchronous task")/await have the same pattern (if you need the synchronization point). That example above is a fork/join pattern but without the words "fork" and "join".



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: