Tried to fix ValueError: signal only works in main thread