upload.py: release the lock in all the cases