def setstate(self, state, info = False, sendevent = False,
                 returnevent = False):
        if state == self._state:
            return []
        self._time = time.time()
        self._state = state
        self.run_state_hooks(state)
        replies = []
        if self.isconnected() and info:
            statename = coreapi.state_name(state)
            with self._handlerslock:
                for handler in self._handlers:
                    handler.info("SESSION %s STATE %d: %s at %s" % \
                                (self.sessionid, state, statename,
                                 time.ctime()))
        self.writestate(state)
        self.runhook(state)
        if sendevent:
            tlvdata = ""
            tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_TYPE,
                                                 state)
            msg = coreapi.CoreEventMessage.pack(0, tlvdata)
            # send Event Message to connected handlers (e.g. GUI)
            if self.isconnected():
                try:
                    if returnevent:
                        replies.append(msg)
                    else:
                        self.broadcastraw(None, msg)
                except Exception, e:
                    self.warn("Error sending Event Message: %s" % e)
            # also inform slave servers
            tmp = self.broker.handlerawmsg(msg)
        return replies
Rendering *emphasis* text.
dataset/ETHPy150Open coreemu/core/daemon/core/session.py/Session.setstate--crossover with--dataset/ETHPy150Open neuroo/equip/examples/sample-test-program/test_module/mistune.py/Renderer.emphasis