mirror of https://github.com/Shizmob/pydle.git
Add more robust connectivity checking.
This commit is contained in:
parent
c22cc437df
commit
89bcc077d5
|
@ -194,6 +194,9 @@ class Connection:
|
||||||
|
|
||||||
def has_message(self, types=None):
|
def has_message(self, types=None):
|
||||||
""" Determine if this connection has a message ready for processing. """
|
""" 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?
|
# Low-hanging fruit: is there a message ready in the queue?
|
||||||
if len(self.message_queue) > 0:
|
if len(self.message_queue) > 0:
|
||||||
# Is the message of the type we want?
|
# Is the message of the type we want?
|
||||||
|
@ -221,6 +224,9 @@ class Connection:
|
||||||
|
|
||||||
def get_message(self, types=None, retry=False):
|
def get_message(self, types=None, retry=False):
|
||||||
""" Get an IRC message for processing. """
|
""" Get an IRC message for processing. """
|
||||||
|
if not self.connected:
|
||||||
|
raise NotConnected('Not connected.')
|
||||||
|
|
||||||
with self.message_lock:
|
with self.message_lock:
|
||||||
try:
|
try:
|
||||||
# Looking for specific type?
|
# Looking for specific type?
|
||||||
|
|
Loading…
Reference in New Issue