+
+ # optionally use this for main thread profiling:
+ # import cProfile
+ # class ProfiledThread(threading.Thread):
+ # def run(self):
+ # profiler = cProfile.Profile()
+ # profiler.runcall(threading.Thread.run, self)
+ # print('profiled thread finished')
+ # profiler.dump_stats('profile')
+ # c = ProfiledThread(target=self.loop, args=(self.queue,))