Mohd Asim khan
Mohd Asim khan

Reputation: 3

Python thread breaks down silently when run in the background

In django I am using thread to read xlsx file in the background but after sometimes it breaks down silently without giving any errors. Is there any way to start an independent thread not causing random failure?

thread_obj = threading.Thread(
                target=bulk_xlsx_obj.copy_bulk_xlsx
            )
thread_obj.start()

Upvotes: 0

Views: 96

Answers (1)

abysslover
abysslover

Reputation: 788

You could set the thread as Daemon to avoid silent failure as follows:

thread_obj = threading.Thread(
                target=bulk_xlsx_obj.copy_bulk_xlsx
            )
thread_obj.setDaemon(True)
thread_obj.start()

Upvotes: 1

Related Questions