From Python's with to JavaScript's using and try/finally

Stephen Gruppetta 14 Lessons 2h 27m Updated intermediate js py

Python’s with releases a resource only once acquiring it has succeeded, but a finally runs whenever its try started. Port the print shop’s with JobLock(job["id"]): to try/finally with the lock-taking call inside the try, and when another PC already holds job J-314’s lock, the finally deletes that PC’s lock. The run ends with no error.

In this course, you’ll port a print shop’s Python job runner, which locks each job, spools its artwork, sends it to a press, and cleans up even when a job fails, to JavaScript.

By the end of this course, you’ll be able to:

  • Clean up with try/finally, taking the resource on the line before the try
  • Tell which node:fs calls close the files they open, and which resources you must close yourself
  • Release a lock with using and Symbol.dispose, and turn a @contextmanager function into one that returns a disposable
  • Close a connection with await using, and collect a changing set of resources with an AsyncDisposableStack
  • Port the whole job runner to JavaScript

You’ll need Python’s context managers, including @contextmanager, async context managers, and ExitStack, plus Node 26 and the JavaScript for classes, async functions, try and catch, and reading and writing files. The Python examples use Python 3.15.

The course mixes short videos and text lessons with exercises, a project that ports the whole job runner, and a quiz.

What’s Included:

  • 14 Lessons
  • Video Subtitles and Full Transcripts
  • Translated Subtitles in 8 Languages
  • 2 Downloadable Resources
  • Interactive Quiz to Check Your Progress
  • 4 Hands-On Coding Exercises
  • Q&A With JavaScript Experts: Ask a Question
  • Certificate of Completion

Downloadable Resources:

Related Learning Paths:

Project: The Print Shop's Job Runner

2 Lessons 23m

  1. 1. Porting the Job Runner05:35
  2. 2. Exercise: Finish the Job Runner18:00

About Stephen Gruppetta

Stephen obtained a PhD in physics and worked as a physicist in academia for over a decade before becoming a programming educator. He's constantly looking for simple ways to explain complex things.

» More about Stephen

← Browse All Courses