diff --git a/tutorial/pipelines.py b/tutorial/pipelines.py index 57bb6da..ec47349 100644 --- a/tutorial/pipelines.py +++ b/tutorial/pipelines.py @@ -26,12 +26,11 @@ def __init__(self): def process_item(self, item, spider): session = self.Session() exist_quote = session.query(Quote).filter_by(quote_content = item["quote_content"]).first() + session.close() if exist_quote is not None: # the current quote exists raise DropItem("Duplicate item found: %s" % item["quote_content"]) - session.close() else: return item - session.close() class SaveQuotesPipeline(object):