Finally fixed the issue with a hung thread for tcplay encryption, after discovering that "while not foo" behaves differently than "while foo is None".