code: def _handle_sigusr2(sig, stack):
      '''
      Signal handler for SIGUSR2, only available on Unix-like systems
      '''
      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(f _handle_sigusr2(sig, stack):
      '''
      Signal handler for SIGUSR2, only available on Unix-like systems
      '''
      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()
docs: Signal handler for SIGUSR2, only available on Unix-like systems