You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using atexit module (not part of the standard libraries):
importatexitdefcleanup():
# Detach the loop device associated with the image filesystem(f"losetup --detach {LOOP}")
# Register the cleanup function to be called on exitatexit.register(cleanup)
# ... (rest of your script)
or by using signals:
importsignaldefcleanup(signum, frame):
# Detach the loop device associated with the image filesystem(f"losetup --detach {LOOP}")
sys.exit(0)
# Register the signal handler for SIGTERM and SIGINTsignal.signal(signal.SIGTERM, cleanup)
signal.signal(signal.SIGINT, cleanup)
# ... (rest of your script)
Failing to do that leaves the loop device setup perpetually if a problem happens.
The text was updated successfully, but these errors were encountered: