...class PresenceClient: def lineReceived(self, line): d = self.queued.pop(0) if line == 'YES': d.callback(1) elif line == 'NO': d.callback(0) else: d.errback(ValueError(line))