Mastering-Concurrency-in-Python icon indicating copy to clipboard operation
Mastering-Concurrency-in-Python copied to clipboard

NameError in Chapter19/example3

Open Matej-Chmel opened this issue 2 years ago • 0 comments
trafficstars

When running script Chapter19/example3.py a NameError is raised:

scheduler.shutdown()
NameError: name 'scheduler' is not defined

The problem can be fixed by indenting the line 27 under the main guard.

Current version
if __name__ == '__main__':
    scheduler = BackgroundScheduler()
    ...
scheduler.shutdown()
Solution
if __name__ == '__main__':
    scheduler = BackgroundScheduler()
    ...
    scheduler.shutdown()

Matej-Chmel avatar Sep 03 '23 11:09 Matej-Chmel