Update protocol.py

Add exception handling. After exception, wait() returns immediately with an empty tuple.