Message316242
Without thread support, event generation from multiple threads fails immediately. I tried an experiment with callback scheduling. It seems to work -- almost.
thread_event.py runs on 2.7 with non-t tcl. It modifies TkinterHandlres32.py by replacing
self.target.event_generate(c)
with
self.target.after(1, lambda t=self.target: t.event_generate(c))
to schedule the event generation in the main thread.
It also imports either tkinter or Tkinter, and runs for 10 seconds
self.root.after(10000,self.stop)
for a more rigorous test.
However, when I add 2 0s to the delay, to make it 1000 seconds, the main thread and gui crash sometime sooner (100 seconds, say), leaving the worker threads sending indefinitely. One time there was a traceback:
Traceback (most recent call last):
File "F:\dev\tem\thread_event.py", line 55, in <module>
Main().go()
File "F:\dev\tem\thread_event.py", line 35, in go
self.t_cleanup.join()
AttributeError: 'Main' object has no attribute 't_cleanup'
A second time, nothing appeared.
I suspect that without proper locking an .after call was eventually interrupted and the pending scheduled callback data structure corrupted. Mainloop exits without t_cleanup created. |
|
Date |
User |
Action |
Args |
2018-05-06 19:20:11 | terry.reedy | set | recipients:
+ terry.reedy, serhiy.storchaka, Ivan.Pozdeev |
2018-05-06 19:20:11 | terry.reedy | set | messageid: <1525634411.81.0.682650639539.issue33412@psf.upfronthosting.co.za> |
2018-05-06 19:20:11 | terry.reedy | link | issue33412 messages |
2018-05-06 19:20:11 | terry.reedy | create | |
|