Set or create an event loop and a thread pool. :param loop: Asyncio loop to use. :param workers: Amount of threads to use for executing async calls. If not pass it will default to the number of processors on the machine, multiplied by 5.
(self, loop=None, workers=None,
mock_browser: bool = True, *args, **kwargs)
| 741 | """ An async consumable session. """ |
| 742 | |
| 743 | def __init__(self, loop=None, workers=None, |
| 744 | mock_browser: bool = True, *args, **kwargs): |
| 745 | """ Set or create an event loop and a thread pool. |
| 746 | |
| 747 | :param loop: Asyncio loop to use. |
| 748 | :param workers: Amount of threads to use for executing async calls. |
| 749 | If not pass it will default to the number of processors on the |
| 750 | machine, multiplied by 5. """ |
| 751 | super().__init__(*args, **kwargs) |
| 752 | |
| 753 | self.loop = loop or asyncio.get_event_loop() |
| 754 | self.thread_pool = ThreadPoolExecutor(max_workers=workers) |
| 755 | |
| 756 | def request(self, *args, **kwargs): |
| 757 | """ Partial original request func and run it in a thread. """ |