-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
AttributeError: __aenter__ #333
Comments
@lvzhengri I’m glad to hear you resolved your issue! However, I’m not encountering the same error. Could you let me know if you were running one of the examples from the quickest start file or your own code? If it’s your own code, I’d really appreciate it if you could share a snippet so I can take a closer look. Currently, we’re using the nullcontext and enter/exit functions, which should work correctly regardless of where the null context is defined. But I’d like to replicate the issue you faced to find a better solution. Looking forward to your code snippet! |
I had the same problem 3.9.5 Python, solved by modifying async_webcrawler.py |
@lvzhengri plz make a pull request, thx. |
I can confirm we have the same issue on Python 3.9.6, but not on 3.11.5 Any suggestions for workarounds, or waiting on PR? |
@dirkbrnd the PR already merged in 0.4.21, please try |
"I noticed a problem when I tried to extract structured data using the extract_structured_data_using_css_extractor method in the code, it throws an error. The error occurs at the line async with self._lock or nullcontext(), and the message indicates that the aenter method is not found. The async with statement automatically calls the aenter and aexit methods of the object to enter and exit the asynchronous context manager.
Specifically, the issue might lie with either self._lock or nullcontext(). These objects should support asynchronous context management, but one of them might not have implemented the aenter method, causing the error.
Here is the translation of your text into English:
"This approach from GPT doesn't work.
Solution:
Ensure that
self._lock
is an asynchronous lock: Make sure that the lock you are using in your code is an asynchronous lock object, such asasyncio.Lock
. If you are using a synchronous lock (likethreading.Lock
), it cannot be used in anasync with
statement.Ensure that
nullcontext()
is imported: If your Python version is 3.6 or lower,nullcontext
may not be available. In this case, you can importnullcontext
from thecontextlib
module:Check your Python version: If you are using Python 3.6 or lower,
nullcontext
is not supported. In this case, you may consider upgrading Python or using a custom empty context manager:###"
The text was updated successfully, but these errors were encountered: