unset parser, send eof to the parser and then remove it.
(self)
| 202 | return output |
| 203 | |
| 204 | def unset_parser(self): |
| 205 | """unset parser, send eof to the parser and then remove it.""" |
| 206 | if self._parser is None: |
| 207 | return |
| 208 | |
| 209 | # TODO: write test |
| 210 | if hasattr(self._loop, 'is_closed'): |
| 211 | if self._loop.is_closed(): |
| 212 | # TODO: log something |
| 213 | return |
| 214 | |
| 215 | try: |
| 216 | self._parser.throw(EofStream()) |
| 217 | except StopIteration: |
| 218 | self._output.feed_eof() |
| 219 | except EofStream: |
| 220 | self._output.set_exception(self._eof_exc_class()) |
| 221 | except Exception as exc: |
| 222 | self._output.set_exception(exc) |
| 223 | finally: |
| 224 | self._output = None |
| 225 | self._parser = None |
| 226 | |
| 227 | |
| 228 | class StreamWriter(asyncio.streams.StreamWriter): |