Handle one message and modify the job storage appropriately.
        :param msg: the message to handle
        :return: None
343368
def handle_single_message(self, msg):
        
        job_id = msg.message['job_id']
        actual_msg = msg.message
        if msg.type == MessageType.JOB_UPDATED:
            progress = actual_msg['progress']
            total_progress = actual_msg['total_progress']
            self.storage_backend.update_job_progress(job_id, progress,
                                                     total_progress)
        elif msg.type == MessageType.JOB_COMPLETED:
            self.storage_backend.complete_job(job_id)
        elif msg.type == MessageType.JOB_FAILED:
            exc = actual_msg['exception']
            trace = actual_msg['traceback']
            self.storage_backend.mark_job_as_failed(job_id, exc, trace)
        elif msg.type == MessageType.JOB_CANCELED:
            self.storage_backend.mark_job_as_canceled(job_id)
        else:
            self.logger.error("Unknown message type: {}".format(msg.type))
1287387
def handleOrders(self, msg):
        
        """
        It is possible that orderStatus() may return duplicate messages.
        It is essential that you filter the message accordingly.
        """

        # log handler msg
        self.log_msg("order", msg)

        # get server time
        self.getServerTime()
        time.sleep(0.001)

        # we need to handle mutiple events for the same order status
        duplicateMessage = False

        # open order
        if msg.typeName == dataTypes["MSG_TYPE_OPEN_ORDER"]:
            # contract identifier
            contractString = self.contractString(msg.contract)

            order_account = ""
            if msg.orderId in self.orders and self.orders[msg.orderId]["status"] == "SENT":
                order_account = self.orders[msg.orderId]["account"]
                try:
                    del self.orders[msg.orderId]
                except Exception:
                    pass

            if msg.orderId in self.orders:
                duplicateMessage = True
            else:
                self.orders[msg.orderId] = {
                    "id":       msg.orderId,
                    "symbol":   contractString,
                    "contract": msg.contract,
                    "order":    msg.order,
                    "status":   "OPENED",
                    "reason":   None,
                    "avgFillPrice": 0.,
                    "parentId": 0,
                    "time": datetime.fromtimestamp(int(self.time)),
                    "account": order_account
                }
                self._assgin_order_to_account(self.orders[msg.orderId])

        # order status
        elif msg.typeName == dataTypes["MSG_TYPE_ORDER_STATUS"]:
            if msg.orderId in self.orders and self.orders[msg.orderId]['status'] == msg.status.upper():
                duplicateMessage = True
            else:
                # remove cancelled orphan orders
                # if "CANCELLED" in msg.status.upper() and msg.parentId not in self.orders.keys():
                #     try: del self.orders[msg.orderId]
                #     except Exception: pass
                # # otherwise, update order status
                # else:
                self.orders[msg.orderId]['status']       = msg.status.upper()
                self.orders[msg.orderId]['reason']       = msg.whyHeld
                self.orders[msg.orderId]['avgFillPrice'] = float(msg.avgFillPrice)
                self.orders[msg.orderId]['parentId']     = int(msg.parentId)
                self.orders[msg.orderId]['time']         = datetime.fromtimestamp(int(self.time))

            # remove from orders?
            # if msg.status.upper() == 'CANCELLED':
            #     del self.orders[msg.orderId]

        # fire callback
        if duplicateMessage is False:
            # group orders by symbol
            self.symbol_orders = self.group_orders("symbol")
            self.ibCallback(caller="handleOrders", msg=msg)
148173
def handleServerEvents(self, msg):
        

        self.log.debug('MSG %s', msg)
        self.handleConnectionState(msg)

        if msg.typeName == "error":
            self.handleErrorEvents(msg)

        elif msg.typeName == dataTypes["MSG_CURRENT_TIME"]:
            if self.time < msg.time:
                self.time = msg.time

        elif (msg.typeName == dataTypes["MSG_TYPE_MKT_DEPTH"] or
                msg.typeName == dataTypes["MSG_TYPE_MKT_DEPTH_L2"]):
            self.handleMarketDepth(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_TICK_STRING"]:
            self.handleTickString(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_TICK_PRICE"]:
            self.handleTickPrice(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_TICK_GENERIC"]:
            self.handleTickGeneric(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_TICK_SIZE"]:
            self.handleTickSize(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_TICK_OPTION"]:
            self.handleTickOptionComputation(msg)

        elif (msg.typeName == dataTypes["MSG_TYPE_OPEN_ORDER"] or
                msg.typeName == dataTypes["MSG_TYPE_OPEN_ORDER_END"] or
                msg.typeName == dataTypes["MSG_TYPE_ORDER_STATUS"]):
            self.handleOrders(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_HISTORICAL_DATA"]:
            self.handleHistoricalData(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_ACCOUNT_UPDATES"]:
            self.handleAccount(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_PORTFOLIO_UPDATES"]:
            self.handlePortfolio(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_POSITION"]:
            self.handlePosition(msg)

        elif msg.typeName == dataTypes["MSG_TYPE_NEXT_ORDER_ID"]:
            self.handleNextValidId(msg.orderId)

        elif msg.typeName == dataTypes["MSG_CONNECTION_CLOSED"]:
            self.handleConnectionClosed(msg)

        # elif msg.typeName == dataTypes["MSG_TYPE_MANAGED_ACCOUNTS"]:
        #     self.accountCode = msg.accountsList

        elif msg.typeName == dataTypes["MSG_COMMISSION_REPORT"]:
            self.commission = msg.commissionReport.m_commission

        elif msg.typeName == dataTypes["MSG_CONTRACT_DETAILS"]:
            self.handleContractDetails(msg, end=False)

        elif msg.typeName == dataTypes["MSG_CONTRACT_DETAILS_END"]:
            self.handleContractDetails(msg, end=True)

        elif msg.typeName == dataTypes["MSG_TICK_SNAPSHOT_END"]:
            self.ibCallback(caller="handleTickSnapshotEnd", msg=msg)

        else:
            # log handler msg
            self.log_msg("server", msg)
911976
def remove_message(self, message):
        '''
        
        '''
        if message in self.__messages:
            self.__messages.remove(message)
831358
def _read_message(self):
        
        job = gevent.spawn(super(GConnection, self)._read_message)
        job.join()
934725
def handle_message(msg, connection = {})
    intermediate = Messages::Intermediate.parse(msg)

    if Messages::Request.is_request_message?(intermediate)
      tp << ThreadPoolJob.new(intermediate) { |i|
              handle_request(i, false, connection)
            }

    elsif Messages::Notification.is_notification_message?(intermediate)
      tp << ThreadPoolJob.new(intermediate) { |i|
              handle_request(i, true, connection)
            }

    elsif Messages::Response.is_response_message?(intermediate)
      handle_response(intermediate)

    end

    intermediate
  end
613178
async def __handle_backend_message(self, message):
        
        message_handlers = {
            BackendNewJob: self.__handle_new_job,
            BackendKillJob: self.kill_job,
            Ping: self.__handle_ping
        }
        try:
            func = message_handlers[message.__class__]
        except:
            raise TypeError("Unknown message type %s" % message.__class__)
        self._create_safe_task(func(message))
949610
def _store(self, messages, response, *args, **kwargs):
        
        return [message for message in messages if not message.level in STICKY_MESSAGE_LEVELS]
411354
def handlePosition(self, msg):
        

        # log handler msg
        self.log_msg("position", msg)

        # contract identifier
        contract_tuple = self.contract_to_tuple(msg.contract)
        contractString = self.contractString(contract_tuple)

        # try creating the contract
        self.registerContract(msg.contract)

        # new account?
        if msg.account not in self._positions.keys():
            self._positions[msg.account] = {}

        # if msg.pos != 0 or contractString in self.contracts.keys():
        self._positions[msg.account][contractString] = {
            "symbol":        contractString,
            "position":      int(msg.pos),
            "avgCost":       float(msg.avgCost),
            "account":       msg.account
        }

        # fire callback
        self.ibCallback(caller="handlePosition", msg=msg)
26969
def _handle_spyder_msg(self, msg):
        
        spyder_msg_type = msg['content'].get('spyder_msg_type')
        if spyder_msg_type == 'data':
            # Deserialize data
            try:
                if PY2:
                    value = cloudpickle.loads(msg['buffers'][0])
                else:
                    value = cloudpickle.loads(bytes(msg['buffers'][0]))
            except Exception as msg:
                self._kernel_value = None
                self._kernel_reply = repr(msg)
            else:
                self._kernel_value = value
            self.sig_got_reply.emit()
            return
        elif spyder_msg_type == 'pdb_state':
            pdb_state = msg['content']['pdb_state']
            if pdb_state is not None and isinstance(pdb_state, dict):
                self.refresh_from_pdb(pdb_state)
        elif spyder_msg_type == 'pdb_continue':
            # Run Pdb continue to get to the first breakpoint
            # Fixes 2034
            self.write_to_stdin('continue')
        elif spyder_msg_type == 'set_breakpoints':
            self.set_spyder_breakpoints(force=True)
        else:
            logger.debug("No such spyder message type: %s" % spyder_msg_type)
568435
def on_message(self, client_conn, msg):
        
        MAX_QUEUE_SIZE = 30
        if len(self._msg_queue) >= MAX_QUEUE_SIZE:
            # This should never happen if callers to handle_message wait
            # for its futures to resolve before sending another message.
            # NM 2014-10-06: Except when there are multiple clients. Oops.
            raise RuntimeError('MessageHandlerThread unhandled '
                               'message queue full, not handling message')
        ready_future = Future()
        self._msg_queue.append((ready_future, client_conn, msg))
        self._wake.set()
        return ready_future
151092
def _handle_lrr(self, data):
        
        msg = LRRMessage(data)

        if not self._ignore_lrr_states:
            self._lrr_system.update(msg)
        self.on_lrr_message(message=msg)

        return msg
210142
def handle_msg(self, msg, **config):
        
        match = self.__prefix__.match(msg['topic'])
        if match:
            return match.groups()[-1] or ""
1268736
async def root_message(self, msg, msg_type=None):
        
        await self.root()
        await self.message(msg, msg_type)
608429
def save(self, msg=None):
        
        if msg is None:
            msg = 'Saving %s' % self.name
        log.debug(msg)
        self.repo.addItem(self, msg)
223730
public void handleEOLMessage()
    {
        Iv2EndOfLogMessage msg = new Iv2EndOfLogMessage(m_partitionId);
        MPIEndOfLogTransactionState txnState = new MPIEndOfLogTransactionState(msg);
        MPIEndOfLogTask task = new MPIEndOfLogTask(m_mailbox, m_pendingTasks,
                                                   txnState, m_iv2Masters);
        m_pendingTasks.offer(task);
    }
163387
def handle_message(self, msg):
        
        self._messages.append({
            'type': msg.category,
            'module': msg.module,
            'obj': msg.obj,
            'line': msg.line,
            'column': msg.column,
            'path': msg.path,
            'symbol': msg.symbol,
            'message': str(msg.msg) or '',
            'message-id': msg.msg_id,
        })