:api:`twisted.internet.protocol.ProcessProtocol <ProcessProtocol>` API
547622
def processEnded(self, status):
        
        self.cleanup()

        if status.value.exitCode is None:
            if self._did_timeout:
                err = RuntimeError("Timeout waiting for Tor launch.")
            else:
                err = RuntimeError(
                    "Tor was killed (%s)." % status.value.signal)
        else:
            err = RuntimeError(
                "Tor exited with error-code %d" % status.value.exitCode)

        # hmmm, this log() should probably go away...not always an
        # error (e.g. .quit()
        log.err(err)
        self._maybe_notify_connected(Failure(err))
1343687
def get_process_by_its_id(self, process_type_id, expand=None):
        
        route_values = {}
        if process_type_id is not None:
            route_values['processTypeId'] = self._serialize.url('process_type_id', process_type_id, 'str')
        query_parameters = {}
        if expand is not None:
            query_parameters['$expand'] = self._serialize.query('expand', expand, 'str')
        response = self._send(http_method='GET',
                              location_id='02cc6a73-5cfb-427d-8c8e-b49fb086e8af',
                              version='5.0-preview.2',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('ProcessInfo', response)
83042
function processHandler(fn) {
                if (_.isFunction(handler)) {
                    return fn(null, handler);
                }
                if (_.isString(handler)) {
                    return self.processStringHandler(mycro, handler, fn);
                }
                if (_.isObject(handler)) {
                    // make sure the object defines a `handler` attribute
                    if (!handler.handler) {
                        return fn('Unable to locate handler for ' + verb.toUpperCase() + ' ' + path.toString());
                    }
                    // extend options with any route specific options
                    if (handler.options && _.isObject(handler.options)) {
                        _.extend(options.defaultOptions, handler.options);
                    }
                    // allow route to override policy chain
                    if (handler.policies && _.isArray(handler.policies)) {
                        options.defaultPolicies = handler.policies;
                    }
                    // allow route to augment policy chain
                    if (handler.additionalPolicies && _.isArray(handler.additionalPolicies)) {
                        options.defaultPolicies = options.defaultPolicies.concat(handler.additionalPolicies);
                    }
                    if (_.isFunction(handler.handler)) {
                        return fn(null, handler.handler);
                    }
                    if (_.isString(handler.handler)) {
                        return self.processStringHandler(mycro, handler.handler, fn);
                    }
                }
                return fn('Unsupported handler type for '+ verb.toUpperCase() + ' ' + path.toString());
            }
878230
def get_exitcode_reactor():
    
    from twisted.internet.main import installReactor
    from twisted.internet.selectreactor import SelectReactor

    class ExitCodeReactor(SelectReactor):

        def stop(self, exitStatus=0):
            super(ExitCodeReactor, self).stop()
            self.exitStatus = exitStatus

        def run(self, *args, **kwargs):
            super(ExitCodeReactor, self).run(*args, **kwargs)
            return self.exitStatus

    reactor = ExitCodeReactor()
    installReactor(reactor)
    return reactor
1194087
def process_queue(self):
        
        m = pycurl.CurlMulti()
        m.handles = []

        # Loop the queue and create Curl objects for processing
        for item in self._queue:
            c = self._create_curl(*item)
            m.add_handle(c)
            m.handles.append(c)

        # Process the collected Curl handles
        num_handles = len(m.handles)
        while num_handles:
            while 1:
                # Perform the calls
                ret, num_handles = m.perform()
                if ret != pycurl.E_CALL_MULTI_PERFORM:
                    break
            m.select(1.0)

        # Collect data
        results = []
        for c in m.handles:
            c.status = c.getinfo(c.HTTP_CODE)
            if 'Content-Encoding: gzip' in c.response_headers.getvalue():
                c.body = cStringIO.StringIO(self._gunzip_body(c.body.getvalue()))
            result = { "data" : self._digest_result(c.body.getvalue()), "code": c.status }
            if not c.status or c.status >= 400:
                # Don't throw the exception because some might have succeeded
                result['exception'] = HapiThreadedError(c)

            results.append(result)

            
        # cleanup
        for c in m.handles:
            if hasattr(c, "data_out"):
                c.data_out.close()

            c.body.close()
            c.response_headers.close()
            c.close()
            m.remove_handle(c)

        m.close()
        del m.handles
        self._queue = []

        return results
1264702
def export_process_template(self, id, **kwargs):
        
        route_values = {}
        if id is not None:
            route_values['id'] = self._serialize.url('id', id, 'str')
        route_values['action'] = 'Export'
        response = self._send(http_method='GET',
                              location_id='29e1f38d-9e9c-4358-86a5-cdf9896a5759',
                              version='5.0-preview.1',
                              route_values=route_values,
                              accept_media_type='application/zip')
        if "callback" in kwargs:
            callback = kwargs["callback"]
        else:
            callback = None
        return self._client.stream_download(response, callback=callback)
878482
def current() -> 'Process':
        
        curr = greenlet.getcurrent()
        if not isinstance(curr, Process):
            raise TypeError("Current greenlet does not correspond to a Process instance.")
        return cast(Process, greenlet.getcurrent())
745004
function pidOf( procName, callback ){
    if ( isString( procName )){
        var pids = [];

        procStat( procName, function( err, processes ){
            processes.object.forEach( function( proc ){
                pids.push( proc.pid )
            });

            callback( err, pids )
        })
    } else callback( new Error( 'A non-string process name was supplied' ), null, null )
}
1100648
def rpc(self, request, args):
        
        if request.method != 'POST':
            return self.error(405, request)
        payload = request.get_data(as_text=True) or '{}'
        request_method = request.args.get('method')
        if not request_method:
            return self.error(
                400, request,
                message="A query string parameter method= is missing."
            )
        name_map = self.service.__nirum_method_names__
        try:
            method_facial_name = name_map.behind_names[request_method]
        except KeyError:
            return self.error(
                400,
                request,
                message="Service doesn't have procedure named '{}'.".format(
                    request_method
                )
            )
        try:
            service_method = getattr(self.service, method_facial_name)
        except AttributeError:
            return self.error(
                400,
                request,
                message="Service has no procedure '{}'.".format(
                    request_method
                )
            )
        if not callable(service_method):
            return self.error(
                400, request,
                message="Remote procedure '{}' is not callable.".format(
                    request_method
                )
            )
        try:
            request_json = json.loads(payload)
        except ValueError:
            return self.error(
                400,
                request,
                message="Invalid JSON payload: '{}'.".format(payload)
            )
        type_hints = self.service.__nirum_service_methods__[method_facial_name]
        try:
            arguments = self._parse_procedure_arguments(
                type_hints,
                request_json
            )
        except (NirumProcedureArgumentValueError,
                NirumProcedureArgumentRequiredError) as e:
            return self.error(400, request, message=str(e))
        method_error_types = self.service.__nirum_method_error_types__
        if not callable(method_error_types):  # generated by older compiler
            method_error_types = method_error_types.get
        method_error = method_error_types(method_facial_name, ())
        try:
            result = service_method(**arguments)
        except method_error as e:
            return self._raw_response(400, serialize_meta(e))
        return_type = type_hints['_return']
        if type_hints.get('_v', 1) >= 2:
            return_type = return_type()
        if not self._check_return_type(return_type, result):
            return self.error(
                400,
                request,
                message="Incorrect return type '{0}' "
                        "for '{1}'. expected '{2}'.".format(
                            typing._type_repr(result.__class__),
                            request_method,
                            typing._type_repr(return_type)
                        )
            )
        else:
            return self._raw_response(200, serialize_meta(result))
1092666
def process_request(self, request, client_address):
    
    t = threading.Thread(
      target=self.process_request_thread,
      args=(request, client_address),
      name="PailgunRequestThread",
    )
    t.daemon = self.daemon_threads
    t.start()
471769
@Nullable
  private HttpMethodInfo prepareHandleMethod(HttpRequest httpRequest,
                                             HttpResponder responder, ChannelHandlerContext ctx) throws Exception {
    HttpMethodInfo methodInfo = httpMethodHandler.getDestinationMethod(httpRequest, responder);

    if (methodInfo == null) {
      return null;
    }

    ctx.channel().attr(HttpDispatcher.METHOD_INFO_KEY).set(methodInfo);

    ChannelPipeline pipeline = ctx.channel().pipeline();
    if (methodInfo.isStreaming()) {
      if (pipeline.get("aggregator") != null) {
        pipeline.remove("aggregator");
      }
      if (pipeline.get("continue") == null) {
        pipeline.addAfter("router", "continue", new HttpServerExpectContinueHandler());
      }
    } else {
      if (pipeline.get("continue") != null) {
        pipeline.remove("continue");
      }
      if (pipeline.get("aggregator") == null) {
        pipeline.addAfter("router", "aggregator", new HttpObjectAggregator(chunkMemoryLimit));
      }
    }
    return methodInfo;
  }
471969
def _parse_protocol_psutil(self, conn):
        
        protocol = self.PSUTIL_TYPE_MAPPING.get(conn.type, '')
        family = self.PSUTIL_FAMILY_MAPPING.get(conn.family, '')
        return '{}{}'.format(protocol, family)
1365176
def render_POST(self, request):
        
        from twisted.internet.defer import maybeDeferred
        
        chain = self.factory.newInstance()
        data = request.content.read()
        
        d = maybeDeferred(chain.processRequest, data, request=request, resource=self)
        d.addCallback(chain.processResponse, request=request, resource=self)
        d.addCallback(self._writeResponse, request)
        d.addErrback(self._writeFault, request)
        
        return NOT_DONE_YET
389674
function buildProcessOptions(processes, logRoot, cmdOptions) {
  return _.flatten(_.map(_.keys(processes), function(procKey) {
    var concurrentCount = parser.parseConcurrencyOpts(cmdOptions)[procKey] || 1;
    return _.map(_.range(concurrentCount), function(index) {
      return {
	id: getID(procKey, index),
	user: cmdOptions.user,
	port: cmdOptions.port,
	processCommand: processes[procKey],
	logRoot: logRoot,
	processName: procKey,
	num: index
      };
    });
  }));
}
1201762
def process_get(self, pid):
        
        if not isinstance(pid, baseinteger):
            raise TypeError("pid can only be an instance of type baseinteger")
        guest_process = self._call("processGet",
                     in_p=[pid])
        guest_process = IGuestProcess(guest_process)
        return guest_process
368125
def get_parameters(self, packet_count=None):
        
        params = super(PipeCapture, self).get_parameters(packet_count=packet_count)
        params += ['-r', '-']
        return params
221713
def get_process_triple():
    
    with ffi.OutputString() as out:
        ffi.lib.LLVMPY_GetProcessTriple(out)
        return str(out)