Skip to content

Test Async callback using Contracts #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Ehsan-U opened this issue Feb 17, 2025 · 1 comment
Closed

Test Async callback using Contracts #340

Ehsan-U opened this issue Feb 17, 2025 · 1 comment

Comments

@Ehsan-U
Copy link

Ehsan-U commented Feb 17, 2025

Is there a way to test an async callback using Scrapy contracts? Based on the error message, it seems like there's no support for that. It would be great to have this feature, or maybe I'm missing something. Should I even use contracts in such cases, or is there a better alternative?

----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ehsan/projects/upwork/karim/maryland-scraper/.venv/lib/python3.12/site-packages/scrapy/contracts/__init__.py", line 183, in cb_wrapper
    output = cb(response, **cb_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ehsan/projects/upwork/karim/maryland-scraper/.venv/lib/python3.12/site-packages/scrapy/contracts/__init__.py", line 70, in wrapper
    raise TypeError("Contracts don't support async callbacks")
TypeError: Contracts don't support async callbacks
@elacuesta
Copy link
Member

As you can see from the traceback, the lack of support for async callbacks comes from upstream Scrapy. I'd suggest to open an issue in Scrapy itself if you'd like to start a conversation about it.

Please see #262 for a similar discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants