Python multi-thread fix