| 151 | return msgs |
| 152 | |
| 153 | def _cleanup(self): |
| 154 | for t in list(self.coros.values()): # t.close() may cause self.coros changed size |
| 155 | t.step(SessionClosedException, throw_exp=True) |
| 156 | # in case that the task catch the SessionClosedException, we need to close it manually |
| 157 | t.close() |
| 158 | self.coros = {} # delete session tasks |
| 159 | |
| 160 | # reset the reference, to avoid circular reference |
| 161 | self._on_session_close = None |
| 162 | self._on_task_command = None |
| 163 | |
| 164 | def close(self, nonblock=False): |
| 165 | """关闭当前Session。由Backend调用""" |