Utilities for python thread