mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +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,10 +87,15 @@ class Waiter(BaseHandler):
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
timeout = self.stream().response_timeout
|
timeout = self.stream().response_timeout
|
||||||
|
|
||||||
try:
|
elapsed_time = 0
|
||||||
stanza = self._payload.get(True, timeout)
|
|
||||||
except queue.Empty:
|
|
||||||
stanza = False
|
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)
|
log.warning("Timed out waiting for %s", self.name)
|
||||||
self.stream().remove_handler(self.name)
|
self.stream().remove_handler(self.name)
|
||||||
return stanza
|
return stanza
|
||||||
|
|
|
@ -134,7 +134,6 @@ class Scheduler(object):
|
||||||
if threaded:
|
if threaded:
|
||||||
self.thread = threading.Thread(name='sheduler_process',
|
self.thread = threading.Thread(name='sheduler_process',
|
||||||
target=self._process)
|
target=self._process)
|
||||||
self.thread.daemon = True
|
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
else:
|
else:
|
||||||
self._process()
|
self._process()
|
||||||
|
|
|
@ -466,7 +466,7 @@ class XMLStream(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _handle_session_timeout():
|
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 " + \
|
log.debug("Session start has taken more " + \
|
||||||
"than %d seconds", self.session_timeout)
|
"than %d seconds", self.session_timeout)
|
||||||
self.disconnect(reconnect=self.auto_reconnect)
|
self.disconnect(reconnect=self.auto_reconnect)
|
||||||
|
@ -1055,7 +1055,6 @@ class XMLStream(object):
|
||||||
|
|
||||||
def start_thread(name, target):
|
def start_thread(name, target):
|
||||||
self.__thread[name] = threading.Thread(name=name, target=target)
|
self.__thread[name] = threading.Thread(name=name, target=target)
|
||||||
self.__thread[name].daemon = True
|
|
||||||
self.__thread[name].start()
|
self.__thread[name].start()
|
||||||
|
|
||||||
for t in range(0, HANDLER_THREADS):
|
for t in range(0, HANDLER_THREADS):
|
||||||
|
@ -1255,7 +1254,7 @@ class XMLStream(object):
|
||||||
"""
|
"""
|
||||||
log.debug("Loading event runner")
|
log.debug("Loading event runner")
|
||||||
try:
|
try:
|
||||||
while not self.stop.isSet():
|
while not self.stop.is_set():
|
||||||
try:
|
try:
|
||||||
wait = self.wait_timeout
|
wait = self.wait_timeout
|
||||||
event = self.event_queue.get(True, timeout=wait)
|
event = self.event_queue.get(True, timeout=wait)
|
||||||
|
@ -1320,7 +1319,9 @@ class XMLStream(object):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
while not self.stop.is_set():
|
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:
|
if self.__failed_send_stanza is not None:
|
||||||
data = self.__failed_send_stanza
|
data = self.__failed_send_stanza
|
||||||
self.__failed_send_stanza = None
|
self.__failed_send_stanza = None
|
||||||
|
|
Loading…
Reference in a new issue