def _handle_sigusr2(sig, stack):
 try:
  import yappi
 except ImportError:
  return
 if yappi.is_running():
  yappi.stop()
  filename = 'callgrind.salt-{0}-{1}'.format(int(time.time()), os.getpid())
  destfile = os.path.join(tempfile.gettempdir(), filename)
  yappi.get_func_stats().save(destfile, type='CALLGRIND')
  if sys.stderr.isatty():
   sys.stderr.write('Saved profiling data to: {0}\n'.format(destfile))
  yappi.clear_stats()
 else:
  if sys.stderr.isatty():
   sys.stderr.write('Profiling started\n')
  yappi.start()

def _handle_sigusr2 ( sig , stack ) : try : import yappi except ImportError : return if yappi . is_running ( ) : yappi . stop ( ) filename = 'callgrind.salt-{0}-{1}' . format ( int ( time . time ( ) ) , os . getpid ( ) ) destfile = os . path . join ( tempfile . gettempdir ( ) , filename ) yappi . get_func_stats ( ) . save ( destfile , type = 'CALLGRIND' ) if sys . stderr . isatty ( ) : sys . stderr . write ( 'Saved profiling data to: {0}\n' . format ( destfile ) ) yappi . clear_stats ( ) else : if sys . stderr . isatty ( ) : sys . stderr . write ( 'Profiling started\n' ) yappi . start ( )
signal handler for sigusr2 .