mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-12-24 11:50:53 +00:00
Convert daemon threads back into normal threads.
This may need to be reverted if CTRL-C handling breaks, but everything works fine so far in testing. Resolves issue #95.
This commit is contained in:
parent
d1a945a305
commit
fba60ffff1
3 changed files with 15 additions and 10 deletions
|
@ -87,11 +87,16 @@ class Waiter(BaseHandler):
|
|||
if timeout is None:
|
||||
timeout = self.stream().response_timeout
|
||||
|
||||
try:
|
||||
stanza = self._payload.get(True, timeout)
|
||||
except queue.Empty:
|
||||
stanza = False
|
||||
log.warning("Timed out waiting for %s", self.name)
|
||||
elapsed_time = 0
|
||||
stanza = False
|
||||
while elapsed_time < timeout and not self.stream().stop.is_set():
|
||||
try:
|
||||
stanza = self._payload.get(True, 1)
|
||||
break
|
||||
except queue.Empty:
|
||||
elapsed_time += 1
|
||||
if elapsed_time >= timeout:
|
||||
log.warning("Timed out waiting for %s", self.name)
|
||||
self.stream().remove_handler(self.name)
|
||||
return stanza
|
||||
|
||||
|
|
|
@ -134,7 +134,6 @@ class Scheduler(object):
|
|||
if threaded:
|
||||
self.thread = threading.Thread(name='sheduler_process',
|
||||
target=self._process)
|
||||
self.thread.daemon = True
|
||||
self.thread.start()
|
||||
else:
|
||||
self._process()
|
||||
|
|
|
@ -466,7 +466,7 @@ class XMLStream(object):
|
|||
"""
|
||||
|
||||
def _handle_session_timeout():
|
||||
if not self.session_started_event.isSet():
|
||||
if not self.session_started_event.is_set():
|
||||
log.debug("Session start has taken more " + \
|
||||
"than %d seconds", self.session_timeout)
|
||||
self.disconnect(reconnect=self.auto_reconnect)
|
||||
|
@ -1055,7 +1055,6 @@ class XMLStream(object):
|
|||
|
||||
def start_thread(name, target):
|
||||
self.__thread[name] = threading.Thread(name=name, target=target)
|
||||
self.__thread[name].daemon = True
|
||||
self.__thread[name].start()
|
||||
|
||||
for t in range(0, HANDLER_THREADS):
|
||||
|
@ -1255,7 +1254,7 @@ class XMLStream(object):
|
|||
"""
|
||||
log.debug("Loading event runner")
|
||||
try:
|
||||
while not self.stop.isSet():
|
||||
while not self.stop.is_set():
|
||||
try:
|
||||
wait = self.wait_timeout
|
||||
event = self.event_queue.get(True, timeout=wait)
|
||||
|
@ -1320,7 +1319,9 @@ class XMLStream(object):
|
|||
"""
|
||||
try:
|
||||
while not self.stop.is_set():
|
||||
self.session_started_event.wait()
|
||||
while not self.stop.is_set and \
|
||||
not self.session_started_event.is_set():
|
||||
self.session_started_event.wait(timeout=1)
|
||||
if self.__failed_send_stanza is not None:
|
||||
data = self.__failed_send_stanza
|
||||
self.__failed_send_stanza = None
|
||||
|
|
Loading…
Reference in a new issue