Skip to content
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

[BUG] AttributeError: 'Botright' object has no attribute '_async_class_task_store' #131

Open
Zorkats opened this issue Oct 1, 2024 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Zorkats
Copy link

Zorkats commented Oct 1, 2024

While using botright in an automation script with playwright, I encountered the following error when trying to open a browser with botright_client.new_browser():

Traceback (most recent call last):
  File "playwright5.0.py", line 300, in <module>
    asyncio.run(download_pdfs())
  File "C:\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
  File "C:\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "C:\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete
    return future.result()
  File "playwright5.0.py", line 97, in download_pdfs
    browser = await botright_client.new_browser()
  File "C:\botright\botright.py", line 147, in new_browser
    _proxy: ProxyManager = await ProxyManager(self, proxy)
  File "C:\botright\modules\proxy_manager.py", line 45, in __ainit__
    link(self, botright)
  File "C:\botright\async_class.py", line 221, in link
    who._async_class_task_store = where.__tasks__.get_child()
  File "C:\botright\async_class.py", line 148, in __tasks__
    return self._async_class_task_store
AttributeError: 'Botright' object has no attribute '_async_class_task_store'

Steps to Reproduce:

Install dependencies with pip install botright playwright

Run the following script:
import asyncio
from botright import Botright

async def download_pdfs():
    async with Botright(headless=True) as botright_client:
        browser = await botright_client.new_browser()
        page = await browser.new_page()
        await page.goto("https://example.com")
        print(await page.title())
        await browser.close()

if __name__ == '__main__':
    asyncio.run(download_pdfs())

The error occurs when attempting to launch the browser.

Expected Behavior:

The browser should open in headless mode, navigate to the provided URL, and close without any errors.
Environment:

OS: Windows 10
Python Version: 3.11
Botright Version: 0.5.1
Playwright Version: 1.40.0
hcaptcha-challenger Version: 0.10.1.post2
Other Installed Packages:
    async-class: 0.5.0
    numpy: 1.26.4
    httpx: 0.27.2

Possible Cause:

It seems the issue is related to the initialization of the _async_class_task_store attribute in the Botright class. This attribute may not be properly initialized during the browser launch process.
Solutions Tried:

I followed the official documentation and reinstalled all dependencies in a fresh environment, but the issue persists.
Additional Comments:

This issue seems to be connected with how async_class is integrated into the flow of botright. I would appreciate any guidance on how to resolve this, or if a future update might address this behavior.

@Zorkats Zorkats added bug Something isn't working help wanted Extra attention is needed labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant