Skip to content

Commit

Permalink
Errback and CloseContextRequest fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewZMSU committed Jul 1, 2024
1 parent d1726b4 commit 1f58055
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions scrapypuppeteer/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ def close_used_contexts(self, spider):
msg=f"Successfully closed {len(request.contexts)} contexts with request {response.request}",
)
)
dfd.addErrback(
lambda _: self.service_logger.log(
level=logging.WARNING, msg="Could not close contexts"
)
)
raise DontCloseSpider()


Expand Down
6 changes: 3 additions & 3 deletions scrapypuppeteer/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def __init__(self, contexts: List, **kwargs):
self.is_valid_url = True
url = kwargs.pop("url", "://") # Incorrect url. To be replaced in middleware

kwargs["method"] = "POST",
kwargs["headers"] = Headers({"Content-Type": "application/json"}),
kwargs["body"] = json.dumps(self.contexts),
kwargs["method"] = "POST"
kwargs["headers"] = Headers({"Content-Type": "application/json"})
kwargs["body"] = json.dumps(self.contexts)

super().__init__(url, **kwargs)

Expand Down

0 comments on commit 1f58055

Please sign in to comment.