allow passing a timeout to handle_xmpp_stanza

This commit is contained in:
Jan Dittberner 2015-02-10 09:37:46 +01:00
parent 3ef552ffc1
commit cdc6f159bf

View file

@ -108,10 +108,10 @@ class Xmpp(nagiosplugin.Resource):
def handle_server(self, xmppsocket):
pass
def handle_xmpp_stanza(self, xmppsocket, message_str):
def handle_xmpp_stanza(self, xmppsocket, message_str, timeout=0.1):
xmppsocket.sendall(message_str.encode('utf-8'))
while True:
rready, wready, xready = select([xmppsocket], [], [], 0.1)
rready, wready, xready = select([xmppsocket], [], [], timeout)
if xmppsocket in rready:
data = xmppsocket.recv(4096)
if not data: break