| 717 | |
| 718 | |
| 719 | class HTMLSession(BaseSession): |
| 720 | |
| 721 | def __init__(self, **kwargs): |
| 722 | super(HTMLSession, self).__init__(**kwargs) |
| 723 | |
| 724 | @property |
| 725 | def browser(self): |
| 726 | if not hasattr(self, "_browser"): |
| 727 | self.loop = asyncio.get_event_loop() |
| 728 | if self.loop.is_running(): |
| 729 | raise RuntimeError("Cannot use HTMLSession within an existing event loop. Use AsyncHTMLSession instead.") |
| 730 | self._browser = self.loop.run_until_complete(super().browser) |
| 731 | return self._browser |
| 732 | |
| 733 | def close(self): |
| 734 | """ If a browser was created close it first. """ |
| 735 | if hasattr(self, "_browser"): |
| 736 | self.loop.run_until_complete(self._browser.close()) |
| 737 | super().close() |
| 738 | |
| 739 | |
| 740 | class AsyncHTMLSession(BaseSession): |
no outgoing calls
searching dependent graphs…