Pause profiling.

    Parameters
    ----------
    profile_process : string
        whether to profile kvstore `server` or `worker`.
        server can only be profiled when kvstore is of type dist.
        if this is not passed, defaults to `worker`
777265
def pause(profile_process='worker'):
    
    profile_process2int = {'worker': 0, 'server': 1}
    check_call(_LIB.MXProcessProfilePause(int(1),
                                          profile_process2int[profile_process],
                                          profiler_kvstore_handle))
1287020
def pause(self, payload):
        """"""
        # Pause specific processes, if `keys` is given in the payload
        if payload.get('keys'):
            succeeded = []
            failed = []
            for key in payload.get('keys'):
                success = self.process_handler.pause_process(key)
                if success:
                    succeeded.append(str(key))
                else:
                    failed.append(str(key))

            message = ''
            if len(succeeded) > 0:
                message += 'Paused processes: {}.'.format(', '.join(succeeded))
                status = 'success'
            if len(failed) > 0:
                message += '\nNo running process for keys: {}'.format(', '.join(failed))
                status = 'error'

            answer = {'message': message.strip(), 'status': status}

        # Pause all processes and the daemon
        else:
            if payload.get('wait'):
                self.paused = True
                answer = {'message': 'Pausing daemon, but waiting for processes to finish.',
                          'status': 'success'}
            else:
                self.process_handler.pause_all()
                if not self.paused:
                    self.paused = True
                    answer = {'message': 'Daemon and all processes paused.',
                              'status': 'success'}
                else:
                    answer = {'message': 'Daemon already paused, pausing all processes anyway.',
                              'status': 'success'}

        return answer
5717
def SetStorageProfiler(self, storage_profiler):
    
    self._storage_profiler = storage_profiler
    if self._storage_file:
      self._storage_file.SetStorageProfiler(storage_profiler)
614893
def _call_system_profiler(datatype):
    '''
    
    '''

    p = subprocess.Popen(
        [PROFILER_BINARY, '-detailLevel', 'full',
         '-xml', datatype], stdout=subprocess.PIPE)
    (sysprofresults, sysprof_stderr) = p.communicate(input=None)

    if six.PY2:
        plist = plistlib.readPlistFromString(sysprofresults)
    else:
        plist = plistlib.readPlistFromBytes(sysprofresults)

    try:
        apps = plist[0]['_items']
    except (IndexError, KeyError):
        apps = []

    return apps
169100
def _wait_while_in_pause_or_in_step_mode(self):
        
        while (self._status.execution_mode is StateMachineExecutionStatus.PAUSED) \
                or (self._status.execution_mode is StateMachineExecutionStatus.STEP_MODE):
            try:
                self._status.execution_condition_variable.acquire()
                self.synchronization_counter += 1
                logger.verbose("Increase synchronization_counter: " + str(self.synchronization_counter))
                self._status.execution_condition_variable.wait()
            finally:
                self._status.execution_condition_variable.release()
619777
def _periodically_flush_profile_events(self):
        """"""
        # Note(rkn): This is run on a background thread in the driver. It uses
        # the raylet client. This should be ok because it doesn't read
        # from the raylet client and we have the GIL here. However,
        # if either of those things changes, then we could run into issues.
        while True:
            # Sleep for 1 second. This will be interrupted if
            # self.threads_stopped is set.
            self.threads_stopped.wait(timeout=1)

            # Exit if we received a signal that we should stop.
            if self.threads_stopped.is_set():
                return

            self.flush_profile_data()
299874
function Profiler(logger, name, level) {
  this.logger = logger;
  this.name = name;
  this.times = 0;
  this.diff = 0;
  this.paused = true;
  this.level = level || 'debug';
}
268714
def get_execution_profile(self, name):
        
        profiles = self.cluster.profile_manager.profiles
        try:
            return profiles[name]
        except KeyError:
            raise ValueError("Invalid execution_profile: '%s'; valid profiles are %s" % (name, profiles.keys()))
920852
def __profile_definition(self, pipeline_name):
        
        pipe = self.flsh.Operations[pipeline_name]
        x_st = pipe.GetUserVariable(PROFILE_LENGTH_ST).Variable()
        x_non_st = pipe.GetUserVariable(PROFILE_LENGTH_NON_ST).Variable()
        timesteps = pipe.GetUserVariable(PROFILE_TIME).Variable()
        self.pipes[pipeline_name] = {'grid': x_st,
                                     'non_st_grid': x_non_st,
                                     'timesteps': timesteps,
                                     'data': {}
                                    }
        return pipe
1174063
def _StopProcessStatusRPCServer(self):
    """"""
    if not self._rpc_server:
      return

    # Make sure the engine gets one more status update so it knows
    # the worker has completed.
    self._WaitForStatusNotRunning()

    self._rpc_server.Stop()
    self._rpc_server = None
    self.rpc_port.value = 0

    logger.debug(
        'Process: {0!s} process status RPC server stopped'.format(self._name))
47710
def profile(prof=None, instances=None, opts=None, **kwargs):
    '''
    
    '''
    if prof is None and 'profile' in kwargs:
        prof = kwargs['profile']

    if prof is None:
        return {'Error': 'A profile (or prof) must be defined'}

    if instances is None and 'names' in kwargs:
        instances = kwargs['names']

    if instances is None:
        return {'Error': 'One or more instances (comma-delimited) must be set'}

    client = _get_client()
    if isinstance(opts, dict):
        client.opts.update(opts)
    info = client.profile(prof, instances, **salt.utils.args.clean_kwargs(**kwargs))
    return info
871866
def runprofilerandshow(funcname, profilepath, argv='', *args, **kwargs):
    '''
    
    '''
    functionprofiler.runprofile(funcname+'(\''+argv+'\')', profilepath, *args, **kwargs)
    print 'Showing profile (windows should open in the background)'; sys.stdout.flush();
    functionprofiler.browseprofilegui(profilepath)
1327307
def on_broker_exit(self):
        
        if not self.profiling:
            # In normal operation we presently kill the process because there is
            # not yet any way to cancel connect(). When profiling, threads
            # including the broker must shut down gracefully, otherwise pstats
            # won't be written.
            os.kill(os.getpid(), signal.SIGTERM)
1136185
def pause_process(msg)

      root = @storage.find_root_expression(msg['wfid'])

      return unless root

      @storage.put_msg(
        msg['action'] == 'pause_process' ? 'pause' : 'resume',
        'fei' => root['fei'],
        'wfid' => msg['wfid']) # it was triggered by {pause|resume}_process
    end
1182772
def flaskrun(app, default_host="127.0.0.1", default_port="8000"):
    

    # Set up the command-line options
    parser = optparse.OptionParser()
    parser.add_option(
        "-H",
        "--host",
        help="Hostname of the Flask app " + "[default %s]" % default_host,
        default=default_host,
    )
    parser.add_option(
        "-P",
        "--port",
        help="Port for the Flask app " + "[default %s]" % default_port,
        default=default_port,
    )

    # Two options useful for debugging purposes, but
    # a bit dangerous so not exposed in the help message.
    parser.add_option(
        "-d", "--debug", action="store_true", dest="debug", help=optparse.SUPPRESS_HELP
    )
    parser.add_option(
        "-p",
        "--profile",
        action="store_true",
        dest="profile",
        help=optparse.SUPPRESS_HELP,
    )

    options, _ = parser.parse_args()

    # If the user selects the profiling option, then we need
    # to do a little extra setup
    if options.profile:
        from werkzeug.contrib.profiler import ProfilerMiddleware

        app.config["PROFILE"] = True
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])
        options.debug = True

    app.run(debug=options.debug, host=options.host, port=int(options.port))
730411
def pause(self):
        
        if self.instance_id is None:
            raise ValueError("Trying to stop unstarted node.")
        resp = self._cloud_provider.pause_instance(self.instance_id)
        self.preferred_ip = None
        return resp
90794
def scan_tasks(self, ignore_shutdown=False):
        ''''''
        for row in self.liststore:
            if len(self.workers.keys()) >= self.app.profile['concurr-download']:
                break
            if row[STATE_COL] == State.WAITING:
                self.start_worker(row)

        if not self.shutdown_button.get_active() or ignore_shutdown:
            return
        # Shutdown system after all tasks have finished
        for row in self.liststore:
            if (row[STATE_COL] not in
                    (State.PAUSED, State.FINISHED, State.CANCELED)):
                return
        self.shutdown.shutdown()