1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-22 21:23:50 +00:00

media pipeline: no need for complex deferred execution

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40397
This commit is contained in:
Daniel Grana 2008-11-24 10:17:02 +00:00
parent a6ff165332
commit 0938984de0

View File

@ -65,14 +65,11 @@ class MediaPipeline(object):
# add to pending list for this request, and wait for result like the others.
info.waiting.setdefault(fp, []).append(wad)
# if request is already downloading, just wait.
if fp in info.downloading:
return wad # break
# if request is not downloading, download it.
if fp not in info.downloading:
self._download(request, info, fp)
# if not, this is the first time for request, try to download it.
dfd = self._download(request, info, fp)
dfd.addCallback(lambda _: wad)
return dfd
return wad
def _download(self, request, info, fp):
def _bugtrap(_failure):
@ -109,7 +106,6 @@ class MediaPipeline(object):
# defer pre-download request processing
dfd = mustbe_deferred(self.media_to_download, request, info)
dfd.addCallback(_evaluated)
return dfd
### Overradiable Interface
def download(self, request, info):