fixing embedding Python multithread problems