0

I'm creating a selenium bot using python and have to use multithreading to speed up the process of getting my information scraped from different menus for different restaurants. I have a couple threads running, scraping the menus but ocassionally a thread will crash, failing to get the menu for that restaurant. The goal is to return the thread number that crashed, so that I can try again running a thread on that restaurant.

I have a simple start, that will initiate the threads and a join that will make sure to only continue once all threads are done. Is there a way to catch an exception and for the child thread to return its identity back to the main thread?

  # Start
        for t in threads:
            t.start()
        
        # Join
        for t in threads:
            t.join()
  • This might help: [Catch a thread's exception in the caller thread](https://stackoverflow.com/questions/2829329/catch-a-threads-exception-in-the-caller-thread) – sj95126 Aug 01 '22 at 23:25
  • I think you don't need to create thread when it is failed, if your thread failing somewhere, you can use `try except` block in your thread – Veysel Olgun Aug 02 '22 at 11:53

0 Answers0