mirror of https://github.com/scrapy/scrapy.git
fixed priority handling on the new scheduler so that it's backwards compatible (ie. bigger priorities are higher). also fixed a few documentation bugs related to requests priority
This commit is contained in:
parent
ee40aa1223
commit
9d97e73a24
|
|
@ -77,11 +77,10 @@ Request objects
|
|||
body to ``str`` (if given as ``unicode``).
|
||||
:type encoding: string
|
||||
|
||||
:param priority: the priority of this request (defaults to ``0.0``).
|
||||
The priority is used by the scheduler to define the order used to return
|
||||
requests. It can also be used to feed priorities externally, for
|
||||
example, using an offline long-term scheduler.
|
||||
:type encoding: int or float
|
||||
:param priority: the priority of this request (defaults to ``0``).
|
||||
The priority is used by the scheduler to define the order used to process
|
||||
requests.
|
||||
:type priority: int
|
||||
|
||||
:param dont_filter: indicates that this request should not be filtered by
|
||||
the scheduler. This is used when you want to perform an identical
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ DEPTH_PRIORITY
|
|||
|
||||
Default: ``1``
|
||||
|
||||
An integer that is used to set the request priority based on request depth.
|
||||
An integer that is used to adjust the request priority based on its depth.
|
||||
|
||||
To crawl in `breadth-first order`_, set :setting:`DEPTH_PRIORITY` to ``1``.
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class DepthMiddleware(object):
|
|||
depth = response.request.meta['depth'] + 1
|
||||
request.meta['depth'] = depth
|
||||
if self.prio:
|
||||
request.priority += depth * self.prio
|
||||
request.priority -= depth * self.prio
|
||||
if self.maxdepth and depth > self.maxdepth:
|
||||
log.msg("Ignoring link (depth > %d): %s " % (self.maxdepth, request.url), \
|
||||
level=log.DEBUG, spider=spider)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class Scheduler(object):
|
|||
return
|
||||
try:
|
||||
reqd = request_to_dict(request, self.spider)
|
||||
self.dqs.push(reqd, request.priority)
|
||||
self.dqs.push(reqd, -request.priority)
|
||||
except ValueError: # non serializable request
|
||||
return
|
||||
else:
|
||||
|
|
@ -67,7 +67,7 @@ class Scheduler(object):
|
|||
|
||||
def _mqpush(self, request):
|
||||
stats.inc_value('scheduler/memory_enqueued', spider=self.spider)
|
||||
self.mqs.push(request, request.priority)
|
||||
self.mqs.push(request, -request.priority)
|
||||
|
||||
def _dqpop(self):
|
||||
if self.dqs:
|
||||
|
|
|
|||
Loading…
Reference in New Issue