Changeset 3831


Ignore:
Timestamp:
Jul 19, 2013 3:39:50 PM (8 years ago)
Author:
clarksm
Message:

Patch to prevent exit when getCommandOutput is used in a thread.
Signals can be handled only in the main thread.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lang/python/Rappture/tools.py

    r3643 r3831  
    1414import select
    1515import signal
     16import traceback
    1617
    1718commandPid = 0
     
    2728    global commandPid
    2829
    29     sig_INT_handler = signal.signal(signal.SIGINT,sig_handler)
    30     sig_HUP_handler = signal.signal(signal.SIGHUP,sig_handler)
    31     sig_TERM_handler = signal.signal(signal.SIGTERM,sig_handler)
     30    try:
     31       sig_INT_handler = signal.signal(signal.SIGINT,sig_handler)
     32       sig_HUP_handler = signal.signal(signal.SIGHUP,sig_handler)
     33       sig_TERM_handler = signal.signal(signal.SIGTERM,sig_handler)
     34    except ValueError:
     35#      happens when used in a thread
     36       pass
     37    except:
     38       print traceback.format_exc()
    3239
    3340    BUFSIZ = 4096
     
    95102    commandPid = 0
    96103
    97     signal.signal(signal.SIGINT,sig_INT_handler)
    98     signal.signal(signal.SIGHUP,sig_HUP_handler)
    99     signal.signal(signal.SIGTERM,sig_TERM_handler)
     104    try:
     105       signal.signal(signal.SIGINT,sig_INT_handler)
     106       signal.signal(signal.SIGHUP,sig_HUP_handler)
     107       signal.signal(signal.SIGTERM,sig_TERM_handler)
     108    except UnboundLocalError:
     109#      happens when used in a thread
     110       pass
     111    except:
     112       print traceback.format_exc()
    100113
    101114    if err != 0:
Note: See TracChangeset for help on using the changeset viewer.