Can't http://docs.python.org/2/library/thread.html#thread.get_ident be used here instead? It existed in 2.5 and in all other paramikos supported versions.