Vinyzu / Vinyzu/Botright

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

Open
#131 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
Python
Stars
1k
Forks
85
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided script with Python 3.11, Botright 0.5.1, and async-class 0.5.0. Read botright.py, modules/proxy_manager.py, and async_class.py around Botright initialization and link(); the work is done when new_browser() opens the browser and the example reaches example.com without the AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.