File Bajjer-0.2.5-io.patch of Package python-bajjer
diff -up Bajjer-0.2.5/gov/lbl/dsd/bajjer/io.py.io Bajjer-0.2.5/gov/lbl/dsd/bajjer/io.py
--- Bajjer-0.2.5/gov/lbl/dsd/bajjer/io.py.io 2007-01-18 07:23:14.000000000 +1000
+++ Bajjer-0.2.5/gov/lbl/dsd/bajjer/io.py 2007-12-19 11:22:44.000000000 +1000
@@ -16,6 +16,12 @@ import socket, logging, threading
import time, re
from gov.lbl.dsd.bajjer import ssl
+try:
+ from OpenSSL.SSL import SysCallError as SSLSysCallError
+except ImportError:
+ # if failed to import OpenSSL, define dummy class
+ class SSLSysCallError: pass
+
__author__ = "Matt Rodriguez, MKRodriguez@lbl.gov"
__created__ = "1 January 2005"
@@ -50,10 +56,12 @@ class CallbackThread(threading.Thread):
messages.
"""
while True:
+ gotData = 0
for conn, cbq in self._cb_queue_dict.items():
for stanza_type, func_tuple in cbq.cb_dict.items():
stanza_obj = conn.read(expected=stanza_type, blocking=False)
if stanza_obj is not None:
+ gotData = 1
func = func_tuple[0]
arg_tuple = func_tuple[1]
if arg_tuple is None:
@@ -64,7 +72,8 @@ class CallbackThread(threading.Thread):
for obj in arg_tuple:
arg_list.append(obj)
func(*arg_list)
- time.sleep(0.1)
+ if not gotData:
+ time.sleep(0.1)
class CallbackQueue:
"""
@@ -157,6 +166,9 @@ class Connection:
except socket.error:
self._lock.release()
return None
+ except SSLSysCallError:
+ self._lock.release()
+ return None
if debugOn():
g_log.debug("RECV: %s" % data)