向会话发送来自用户浏览器的事件️ :param dict event: 事件️消息
(self, event)
| 142 | return event |
| 143 | |
| 144 | def send_client_event(self, event): |
| 145 | """向会话发送来自用户浏览器的事件️ |
| 146 | |
| 147 | :param dict event: 事件️消息 |
| 148 | """ |
| 149 | task_id = event['task_id'] |
| 150 | mq = self.task_mqs.get(task_id) |
| 151 | if not mq and task_id in self.callbacks: |
| 152 | mq = self.callback_mq |
| 153 | |
| 154 | if not mq: |
| 155 | logger.error('event_mqs not found, task_id:%s', task_id) |
| 156 | return |
| 157 | |
| 158 | try: |
| 159 | mq.put_nowait(event) # disable blocking, because this is call by backend |
| 160 | except queue.Full: |
| 161 | logger.error('Message queue is full, discard new messages') # todo: alert user |
| 162 | |
| 163 | def get_task_commands(self): |
| 164 | return self.unhandled_task_msgs.get() |