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.
If I run the following code:
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!