How to fix RuntimeError: Lock is not acquired in Python | DevErrors