From 774364b6d35b39bb9ef7ba000c3e906f95902140 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Sun, 11 Jan 2026 19:57:03 +0200 Subject: [PATCH] style(spiders): make the usage of uvloop optional --- scrapling/spiders/spider.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scrapling/spiders/spider.py b/scrapling/spiders/spider.py index fbaa5f4..5c51071 100644 --- a/scrapling/spiders/spider.py +++ b/scrapling/spiders/spider.py @@ -195,15 +195,16 @@ class Spider(ABC): if isinstance(handler, logging.FileHandler): handler.close() - def start(self, backend_options: Dict[str, Any] | None = None) -> CrawlResult: + def start(self, use_uvloop: bool = False, **backend_options: Any) -> CrawlResult: """Run the spider and return results. This is the main entry point for running a spider. Handles async execution internally via anyio. + :param use_uvloop: Whether to use the faster uvloop/winloop event loop implementation, if available. :param backend_options: Asyncio backend options to be used with `anyio.run` """ backend_options = backend_options or {} - # By default use the faster uvloop/winloop event loop implementation, if available - backend_options.update({"use_uvloop": True}) + if use_uvloop: + backend_options.update({"use_uvloop": True}) return anyio.run(self.__run, backend="asyncio", backend_options=backend_options)