Parse the message from the thread or just passthrough to the Electron Renderer Process concerned
551234
function ParseMessageFromThread(o) {
    var o = UnserializeFromProcess(o);
    if (typeof(o) == "object" && o.name && o.args) {

        // Process response from the thread
        // Electron: If we are in the Main Process, and it is not a global message, we executed it too
        if (!isElectron || electron.ipcRenderer || !o.electronSenderId) {
            var args = o.args;
            var name = o.name;
            ThreadMessage[name].apply(ThreadMessage, args);
        } else {
            // Electron: Send the message to the correct window
            var electronSenderId = o.electronSenderId;
            ipc.sendTo(electronSenderId, "threadify-message", o);
        }
    }
}
144329
def _message(self, bus, message):
        
        if not self.finished:
            if message.type == Gst.MessageType.EOS:
                # The file is done. Tell the consumer thread.
                self.queue.put(SENTINEL)
                if not self.got_caps:
                    # If the stream ends before _notify_caps was called, this
                    # is an invalid file.
                    self.read_exc = NoStreamError()
                    self.ready_sem.release()

            elif message.type == Gst.MessageType.ERROR:
                gerror, debug = message.parse_error()
                if 'not-linked' in debug:
                    self.read_exc = NoStreamError()
                elif 'No such file' in debug:
                    self.read_exc = IOError('resource not found')
                else:
                    self.read_exc = FileReadError(debug)
                self.ready_sem.release()
145599
def passed(self, message):
        '''
        
        '''
        return self._log(
            message=message.upper(),
            stream=sys.stdout,
            color=Logger.COLOR_GREEN_BOLD,
            newline=True
        )
823524
function handleIncomingMessage(data) {
		var message;
		reader.parse(data, initPending);
		initPending = false;
		while (!reader.isEmpty()) {
			message = reader.pop();
			// console.log("IN MESSAGE: " + inspect(message));
			// Check if there are listeners attached to the event
			// otherwise falls back to the default handler
			if (that.listeners(message.verb).length) {
				handlers[message.verb](message);
			} else {
				defHandlers[message.verb].call(that, message);
			}
		}
	}
215312
def process_stream_line(line)
      return if @mutex.synchronize { @subscriptions.any? { |subscription| subscription.process_stream_data line } }
      return if process_send_message_outcome line

      warn "Lightstreamer: unprocessed stream data '#{line}'"
    end
1096285
function SendThreadRequest(tq) {
    if (!isElectron || electron.ipcMain) { // NodeJS classic process OR NodeJS Electron Process
        var threadId = tq.threadId;
        var scriptFilepath = path.join(path.dirname(module.filename), "thread.js");
        var thread = null;
        var threadObject = null;

        // Anonymous thread
        if (threadId == 0) { // On a free thread, or wait
            for (var i = 0; i < threads.length; i++) {
                threadObject = threads[i];
                if (threadObject.inactive && threadObject.anonymous) {
                    threadObject.inactive = false;
                    thread = threadObject.thread;
                    break;
                } else {
                    Log(3, "[Threadify]", "Thread", threadObject.id, "busy. Checking if others available");
                }
            }

            if (!thread && threads.length < Config.maxThreads) {
                threadObject = {anonymous: true, id: "anonymous"+threads.length, thread: null, inactive: false};
                threads.push(threadObject);
                thread = fork(scriptFilepath);
                thread.on("message", ParseMessageFromThread);
                tq.threadId = threadObject.id;
                threadObject.thread = thread;
            }
        } else {
            // Defined ID thread, we give the request to the correct thread
            var inactiveThreadObject = null;
            var indexInactiveThreadObject = -1;
            for (var i = 0; i < threads.length; i++) {
                threadObject = threads[i];
                if (threadObject.id == threadId) {
					if (threadObject.inactive) {
						threadObject.inactive = false;
						thread = threadObject.thread;
					} else {
						return false; // Directly returning false, because thread is active and we can't surcharge him (Windows crash)
					}
                }
                else if (threadObject.inactive) {
                    // We check for inactive thread, in case the max number of thread is used
                    inactiveThreadObject = threadObject;
                    indexInactiveThreadObject = i;
                }
            }
            if (!thread) {
                // We kill an inactive one for adding this specific thread, or we add one if we are on below
                if (threads.length < Config.maxThreads || inactiveThreadObject) {
                    if (inactiveThreadObject) {
                        inactiveThreadObject.inactive = false;
                        inactiveThreadObject.thread.kill();
                    }
                    threads.splice(indexInactiveThreadObject, 1);
                    threadObject = {anonymous: false, id: threadId, thread: null, inactive: false};
                    threads.push(threadObject);
                    thread = fork(scriptFilepath);
                    thread.on("message", ParseMessageFromThread);
                    threadObject.thread = thread;
                }
            }
        }
        if (!thread) {
            // No threads available
            return false;
        } else {
            Log(1, "[Threadify]", "Sending request", tq.id, "to thread", threadObject.id)
            thread.send(tq);
            return true;
        }
    } else { // Electron Window Process
        // We have to passthrough the request to the ipc, always return true, we don't keep a record of pending request here
        ipc.send("threadify-request", tq);
        return true;
    }
}
1299850
def expose_finish(self, *args):
        
        # Obtain a reference to the OpenGL drawable
        # and rendering context.
        gldrawable = self.get_gl_drawable()
        # glcontext = self.get_gl_context()

        if not gldrawable:
            return

        # Put the buffer on the screen!
        if gldrawable.is_double_buffered():
            gldrawable.swap_buffers()
        else:
            glFlush()

        # OpenGL end
        gldrawable.gl_end()
679224
def handle_stream(self, message):
        
        logging.debug("handle_stream(...)")

        event = Event()
        for line in message.strip().splitlines():
            (field, value) = line.split(":", 1)
            field = field.strip()

            if field == "event":
                event.name = value.lstrip()
            elif field == "data":
                value = value.lstrip()
                if event.data is None:
                    event.data = value
                else:
                    event.data = "%s\n%s" % (event.data, value)
            elif field == "id":
                event.id = value.lstrip()
                self.last_event_id = event.id
            elif field == "retry":
                try:
                    self.retry_timeout = int(value)
                    event.retry = self.retry_timeout
                    logging.info("timeout reset: %s" % (value,))
                except ValueError:
                    pass
            elif field == "":
                logging.debug("received comment: %s" % (value,))
            else:
                raise Exception("Unknown field !")
        self.events.append(event)
720124
def render_thread(self):
    """"""
    obs = True
    while obs:  # Send something falsy through the queue to shut down.
      obs = self._obs_queue.get()
      if obs:
        for alert in obs.observation.alerts:
          self._alerts[sc_pb.Alert.Name(alert)] = time.time()
        for err in obs.action_errors:
          if err.result != sc_err.Success:
            self._alerts[sc_err.ActionResult.Name(err.result)] = time.time()
        self.prepare_actions(obs)
        if self._obs_queue.empty():
          # Only render the latest observation so we keep up with the game.
          self.render_obs(obs)
        if self._video_writer:
          self._video_writer.add(np.transpose(
              pygame.surfarray.pixels3d(self._window), axes=(1, 0, 2)))
      self._obs_queue.task_done()
604416
function processMultiBytePacketStop (o) {
  processMultiBytePacket(o);
  const str = o.multiPacketBuffer.toString();
  o.multiPacketBuffer = null;
  return {
    'message': str
  };
}
1186399
def parse(self):
        ""
        if self._parsed: return
        root = self._root = to_ele(self._raw) # The <rpc-reply> element
        # Per RFC 4741 an <ok/> tag is sent when there are no errors or warnings
        ok = root.find(qualify("ok"))
        if ok is None:
            # Create RPCError objects from <rpc-error> elements
            error = root.find('.//'+qualify('rpc-error'))
            if error is not None:
                for err in root.getiterator(error.tag):
                    # Process a particular <rpc-error>
                    self._errors.append(self.ERROR_CLS(err))
        self._parsing_hook(root)
        self._parsed = True
1346889
function readFailureCallback(e) {
    if (this._readyState === FileReader.DONE) {
        return;
    }

    this._readyState = FileReader.DONE;
    this._result = null;
    this._error = new FileError(e);

    if (typeof this.onerror === "function") {
        this.onerror(new ProgressEvent("error", {target:this}));
    }

    if (typeof this.onloadend === "function") {
        this.onloadend(new ProgressEvent("loadend", {target:this}));
    }
}
1315092
def process(handler)
      logger.debug "Beetle: processing message #{msg_id}"
      result = nil
      begin
        result = process_internal(handler)
        handler.process_exception(@exception) if @exception
        handler.process_failure(result) if result.failure?
      rescue Exception => e
        Beetle::reraise_expectation_errors!
        logger.warn "Beetle: exception '#{e}' during processing of message #{msg_id}"
        logger.warn "Beetle: backtrace: #{e.backtrace.join("\n")}"
        result = RC::InternalError
      end
      result
    end
574527
function parseArgv() {
  const args = {}
  for (const arg of process.argv) {
    const elems = arg.split('=')
    const key = elems[0]
    const val = elems.length > 1 ? elems[1] : true
    args[key] = val
  }
  return args
}
753196
void recivedMessage(final ByteBuffer message, final SynchronizeFXTomcatConnection sender) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("Received a message in thread: id: " + Thread.currentThread().getName() + ", name: "
                    + Thread.currentThread().getName());
        }
        List<Command> commands;
        try {
            commands = serializer.deserialize(message.array());
        } catch (final SynchronizeFXException e) {
            try {
                sender.getWsOutbound().close(0, null);
            } catch (final IOException e1) {
                callback.onClientConnectionError(sender, new SynchronizeFXException(e1));
            }
            callback.onClientConnectionError(sender, e);
            return;
        }
        synchronized (callback) {
            callback.recive(commands, sender);
        }
    }
1239779
function promiseWrapper (resolve, reject) {
            // Wait for the process to exit
            process.on ("exit", (code) => {
                // Did the process crash?
                if (code !== 0) reject (process.stderr.textContent);

                // Resolve
                resolve (process.stdout.textContent);
            });

            // Pipe the script into stdin and end
            process.stdin.write (script);
            process.stdin.end ();
        }
91493
function handleMessageFromMainThread(message) {
    var kind = message.data.kind;
    var payload = message.data.payload;

    if (kind === messageKind.init) {
      graph = fromjson(payload.graph);
      var options = JSON.parse(payload.options);

      init(graph, options);
    } else if (kind === messageKind.step) {
      step();
    } else if (kind === messageKind.pinNode) {
      pinNode(payload.nodeId, payload.isPinned);
    } else if (kind === messageKind.setNodePosition) {
      setNodePosition(payload.nodeId, payload.x, payload.y, payload.z);
    }
    // TODO: listen for graph changes from main thread and update layout here.
  }