Code rewritten to use python twisted

Twisted gives threads out of the box.