qt - Advanced Python Scheduler BlockingScheduler not playing well with QtCore.SIGNAL in PyQt -
i have discovered interesting behaviour don't understand , wondering if has idea going on.
i developing program using pyqt4 , require data received rs485 interface updated every second
to achieve accurately, using advanced python scheduler's (aps) blockingscheduler schedule task every second.
the problem running signals emit main thread not received @ when blockingscheduler used, when use qtcore.qcoreapplication.processevents()
.
i don't quite understand because if have blocking loop in worker thread example:
while(true): print('this loop never ends') qtcore.qcoreapplication.processevents()
all signals thread processed after print statement made. seems blockingscheduler
not exhibit same behaviour this.
i have tried using backgroundscheduler , problem implementation backgroundscheduler seems have different event loop thread called from. results in clashes in communications hardware since there 2 execution loops fighting 1 serial bus.
my code looks this
class main_window(): # ui stuff goes here def go(self): # signal sent here self.emit(signal('do_something')) class worker1(qtcore.qobject): def __init__(self): ... def go_pressed(self): self.sched = blockingscheduler() self.sched.add_job(self.start_monitoring, 'interval', seconds = 1, next_run_time = datetime.now()) self.sched.start() def start_monitoring(self): # data grabbing stuff here qtcore.qcoreapplication.processevents() def do_something(self): # signal received here... # # create our application app = qtgui.qapplication(sys.argv) myapp = main_window() myapp.show() # create qthread , qobject our worker worker = worker1() thr = qtcore.qthread() # move our object new thread worker.movetothread(thr) app.connect(myapp,signal('do_something'),worker.do_something)
so question is:
1) how make blockingscheduler see external signals
2) how make signals wait completion of task scheduled backgroundscheduler
?
3) there better way schedule tasks every second without of being issue?
Comments
Post a Comment