Async JavaScript for Pythonistas (Summary)

Congratulations, you made it to the end of the course! Ashdown Libraries’ holds check now runs in JavaScript. On the first morning, branch-status.js prints the same seven lines as Owen’s branch_status.py, from Northgate: 14 holds waiting to Checked 4 kiosks in 0.5 s. Hollins Green shows no answer, Quarry Hill’s three holds arrive on its second try, and the second morning prints Yesterday: 26.

In Porting the Holds Check, you rebuilt the script up to the board and the total. In the exercise Finish the Holds Check, you completed it, loading yesterday’s total while querying the kiosks, writing today’s total to the history file, and timing the check.

In this course, you learned how to:

  • Port async def to an async function, awaited at the top level without asyncio.run()
  • Pause with setTimeout(), imported as sleep() from node:timers/promises, in milliseconds
  • Recognize the promise an async call returns and await its value
  • Await steps one at a time inside a for...of loop
  • Wait for several promises at once with Promise.all()
  • Keep every outcome with Promise.allSettled()
  • Stop waiting for slow work with Promise.race()
  • Retry a failing call with try/catch around await
  • Keep a promise you await later from stopping the program

Keep the Habits That Carry Over

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.