From 89bcc077d50347e042afa26823692a0a999eb897 Mon Sep 17 00:00:00 2001 From: Shiz Date: Thu, 30 Jan 2014 09:00:57 +0100 Subject: [PATCH] Add more robust connectivity checking. --- pydle/connection.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pydle/connection.py b/pydle/connection.py index b8513fe..07a9c9a 100644 --- a/pydle/connection.py +++ b/pydle/connection.py @@ -194,6 +194,9 @@ class Connection: def has_message(self, types=None): """ Determine if this connection has a message ready for processing. """ + if not self.connected: + return False + # Low-hanging fruit: is there a message ready in the queue? if len(self.message_queue) > 0: # Is the message of the type we want? @@ -221,6 +224,9 @@ class Connection: def get_message(self, types=None, retry=False): """ Get an IRC message for processing. """ + if not self.connected: + raise NotConnected('Not connected.') + with self.message_lock: try: # Looking for specific type?