Use `with` for acquiring and releasing the semaphore