File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1111from scrapy .crawler import Crawler
1212from scrapy .exceptions import NotConfigured
1313from scrapy .http import Request , Response
14+ from scrapy .utils .defer import deferred_from_coro
1415
1516from sh_scrapy import _SCRAPY_NO_SPIDER_ARG
1617
@@ -57,10 +58,15 @@ def __init__(self, crawler: Crawler):
5758
5859 def process_spider_exception (self , response : Response , exception : Exception ) -> None :
5960 if self ._is_disk_quota_error (exception ):
61+ from scrapy .utils .asyncio import is_asyncio_available
62+
6063 coro = self .crawler .engine .close_spider_async (reason = "diskusage_exceeded" )
61- task = asyncio .create_task (coro )
62- self ._tasks .add (task )
63- task .add_done_callback (self ._tasks .discard )
64+ if is_asyncio_available ():
65+ task = asyncio .create_task (coro )
66+ self ._tasks .add (task )
67+ task .add_done_callback (self ._tasks .discard )
68+ else :
69+ deferred_from_coro (coro )
6470
6571 else :
6672
You can’t perform that action at this time.
0 commit comments