worker: use a compatibility layer for persistent hashing

We have to make use of the fast hash function in python 2 and only fall
back to the hashlib in python 3.