I use python version of libtorrent. When I run a torrent session for a longer time with many files, it crashes with an error:
terminate called after throwing an instance of 'boost::lock_error'
what(): boost::lock_error
so, I thought I will wrap the torrent related function into a separate thread and when it crashes, it will kill just the thread (instead of the entire app):
from threading import Thread
class TWrapper (Thread) :
# ...
def run(self):
try:
run_torrent_stuff()
except:
# print message
pass
t = TWrapper()
t.run()
t.join()
# check if all OK with t, if not - restart again
I thought that if the library crashes, the thread will die and I will join it in the main loop. But, when the libtorrent crashes, all the application dies 🙁
Why the error escalates outside the thread?
(libtorrent is an example (real life), the question is general)
Usually if thread crashes, it leads to process crash, if you want to avoid it run libtorrent in a separate process.