mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-30 19:19:55 +00:00
Added try/except for setting signal handlers.
Setting signal handlers from inside a thread is not supported in Python, but some applications need to run Sleek from a child thread. SleekXMPP applications that run inside a child thread will NOT be able to detect SIGHUP or SIGTERM events. Those must be caught and managed by the main program.
This commit is contained in:
parent
9c08e56ed0
commit
973890e2c9
1 changed files with 9 additions and 5 deletions
|
@ -199,11 +199,15 @@ class XMLStream(object):
|
||||||
self.auto_reconnect = True
|
self.auto_reconnect = True
|
||||||
self.is_client = False
|
self.is_client = False
|
||||||
|
|
||||||
|
try:
|
||||||
if hasattr(signal, 'SIGHUP'):
|
if hasattr(signal, 'SIGHUP'):
|
||||||
signal.signal(signal.SIGHUP, self._handle_kill)
|
signal.signal(signal.SIGHUP, self._handle_kill)
|
||||||
if hasattr(signal, 'SIGTERM'):
|
if hasattr(signal, 'SIGTERM'):
|
||||||
# Used in Windows
|
# Used in Windows
|
||||||
signal.signal(signal.SIGTERM, self._handle_kill)
|
signal.signal(signal.SIGTERM, self._handle_kill)
|
||||||
|
except:
|
||||||
|
logging.debug("Can not set interrupt signal handlers. " + \
|
||||||
|
"SleekXMPP is not running from a main thread.")
|
||||||
|
|
||||||
def _handle_kill(self, signum, frame):
|
def _handle_kill(self, signum, frame):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue