crashreporter
crashreporter copied to clipboard
Does not work with multithreaded program.
Please find my code below:
from crashreporter import CrashReporter
#from crashreporter.crashreporter import CrashReporter
import threading
class Person(object):
def __init__(self, name, age=None):
self.name = name
self.age = age
def combine_ages(person_a, person_b):
a_local_variable = 134
return person_a.age + person_b.age, Person.__name__
# Note I have used a configuration file for setting up SMTP and HQ accounts but you can also call functions
# cr.setup_smtp() and cr.setup_hq() with your credentials to configure SMTP/HQ respectively.
cr = CrashReporter(report_dir='./reports',
check_interval=10,
config='./crashreporter.cfg')
cr.application_name = 'My App'
cr.application_version = '1.1.350'
calvin = Person('calvin', age=25)
bob = Person('bob')
job_thread = threading.Thread(target=combine_ages,args=(calvin, bob,))
job_thread.start()
Crash reporter is not reporting exceptions in above case. Kindly help me.
Hi there,
Are you giving enough time for the function to run? If this is the entire code then you are starting the thread and then the code will exit, potentially before the thread gets to running the function.
You should add job_thread.join()
to make sure you wait for the thread to complete.
I let the code run and my core logic of application is below this line so it has more than enough time to run. If I don't run the code on thread, it works fine. But on thread only it doesn't work.
I can't add .join(), as it will stop execution there. My core logic won't be able to execute due to .join().