omkarcloud / botasaurus

The All in One Framework to build Awesome Scrapers.
https://www.omkar.cloud/botasaurus/
MIT License
1.16k stars 104 forks source link

Bug in example of README #22

Closed pabloschz closed 6 months ago

pabloschz commented 6 months ago

If I run the following code:

from botasaurus import browser, AntiDetectDriver  # Replace with your actual scraping library

@browser(async_queue=True, close_on_crash=True)
def scrape_data(driver: AntiDetectDriver, data):
    print("Starting a task.")
    print(data)
    sleep(1)  # Simulate a delay, e.g., waiting for a page to load
    print("Task completed.")
    return data

if __name__ == "__main__":
    # Start scraping tasks without waiting for each to finish
    async_queue = scrape_data()  # Initializes the queue

    # Add tasks to the queue
    async_queue.put([1])
    async_queue.put(4)
    async_queue.put([5, 6])

    # Retrieve results when ready
    results = async_queue.get()  # Expects to receive: [1, 2, 3, 4, 5, 6]

It fail as the queue put method a list, and you are passing it an int. This is solved by changing it to a list. But my question is: How can I make the program fail? because right now the program return an exception but doesn't finish, just stay in hold.

Thanks for the lib, amazing job!

Chetan11-dev commented 6 months ago

Fixed, Run the following command to update packages:

python -m pip install botasaurus --upgrade