Skip to content

Commit

Permalink
from cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
jadbin committed Oct 25, 2017
1 parent a27da6c commit ad62b18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions xpaw/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def __init__(self, proj_dir=None, config=None):
self.dupefilter = self._new_object_from_cluster(self.config.get("dupefilter_cls"), self)
self.downloader = Downloader(timeout=self.config.getfloat("downloader_timeout"),
loop=self.loop)
self.spider = load_object(self.config["spider"])(self.config)
self.spider = self._new_object_from_cluster(self.config.get("spider"), self)
log.debug("Spider: {}".format(".".join((type(self.spider).__module__,
type(self.spider).__name__))))
self.downloadermw = DownloaderMiddlewareManager.from_cluster(self.config)
self.spidermw = SpiderMiddlewareManager.from_cluster(self.config)
self.downloadermw = DownloaderMiddlewareManager.from_cluster(self)
self.spidermw = SpiderMiddlewareManager.from_cluster(self)
self._last_request = None
self._job_futures = None
self._job_futures_done = set()
Expand Down
8 changes: 7 additions & 1 deletion xpaw/spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@


class Spider:
def __init__(self, config):
def __init__(self, config=None, **kwargs):
self.config = config

@classmethod
def from_cluster(cls, cluster):
spider = cls(config=cluster.config)
spider.cluster = cluster
return spider

@property
def logger(self):
return log
Expand Down

0 comments on commit ad62b18

Please sign in to comment.