Might you run on a laptop or other Windows computer that has power management enabled, so that it might go to sleep or hibernate when not being used?
If you do nothing, windows will likely sleep or hibernate before your script can complete.
The following simple piece of code can prevent this problem. When used, it will ask windows not to sleep while the script runs. (In some cases, such as when the battery is running out, Windows will ignore your request.)
'''Prevent OS sleep/hibernate in windows; code from:
ES_CONTINUOUS = 0x80000000
ES_SYSTEM_REQUIRED = 0x00000001
print("Preventing Windows from going to sleep")
WindowsInhibitor.ES_CONTINUOUS | \
print("Allowing Windows to go to sleep")
To run it, simply:
osSleep = None
# in Windows, prevent the OS from sleeping while we run
if os.name == 'nt':
osSleep = WindowsInhibitor()
# do slow stuff
It is based on code from here, which also has code for preventing suspension on Linux under GNOME and KDE, should you need that.