Fix issue with Python type initialization in separate thread