def worker_no_with(lock, stream): lock.acquire() try: stream.write('Lock acquired directly\n') finally: lock.release()