Define macros to abstract away the details of thread local storage
Attempt at fixing thread local storage in python