Attempt at fixing thread local storage in python