Skip to content

Commit

Permalink
pipeline 支持close方法
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris-code committed Sep 22, 2021
1 parent 2901413 commit 493ff7b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion feapder/buffer/item_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,9 @@ def check_datas(self, table, datas):
metrics.emit_counter(k, int(bool(v)), classify=table)

def close(self):
pass
# 调用pipeline的close方法
for pipeline in self._pipelines:
try:
pipeline.close()
except:
pass
1 change: 1 addition & 0 deletions feapder/core/spiders/air_spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def run(self):
self.end_callback()
# 为了线程可重复start
self._started.clear()
# 关闭打点
metrics.close()

def join(self, timeout=None):
Expand Down
8 changes: 8 additions & 0 deletions feapder/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ def update_items(self, table, items: List[Dict], update_keys=Tuple) -> bool:
"""

return True

def close(self):
"""
关闭,爬虫结束时调用
Returns:
"""
pass

0 comments on commit 493ff7b

Please sign in to comment.