[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] bpo-33257: seeking advice & approval on the course of action

On 14.05.2018 22:05, Ivan Pozdeev wrote:
> On 14.05.2018 21:58, Terry Reedy wrote:
>> On 5/14/2018 12:20 PM, Chris Barker via Python-Dev wrote:
>>> On Wed, May 2, 2018 at 8:21 PM, Terry Reedy <tjreedy at udel.edu 
>>> <mailto:tjreedy at udel.edu>> wrote:
>>> ??? On 5/2/2018 4:38 PM, Ivan Pozdeev via Python-Dev wrote:
>>> ??????? The bottom line is: Tkinter is currently broken
>>> ??? This is way over-stated.? Many modules have bugs, somethings in
>>> ??? features more central to their main purpose.
>>> I'll suggest a re-statement:
>>> tkinter is not thread safe,
>> Still over-stated.? If one uses tcl/tk compiled with thread support, 
>> tkinter *is* thread-safe.? This is 'as far as I know' from running 
>> posted 'failing' examples (possible with bug fixes) with 3.5+ on 
>> Windows, which is installed with tcl/tk 8.6, which defaults to 
>> thread-safe.
> This means that you didn't (yet) read the letter that I attached to 
> https://bugs.python.org/issue33479 .
> Reciting the relevant section:
> ===
> The reality is that with neither flavor of Tcl is Tkinter completely 
> thread-safe, but with threaded flavor, it's more so:
> * with nonthreaded Tcl, making concurrent Tcl calls leads to crashes 
> due to incorrect management of the "Tcl lock" as per 
> https://bugs.python.org/issue33257
> * with threaded Tcl, the only issue that I found so far is that a few 
> APIs must be called from the interpreter's thread 
> (https://bugs.python.org/issue33412#msg316152; so far, I know 
> `mainloop()` and `destroy()` to be this) -- while most can be called 
> from anywhere. Whether the exceptions are justified is a matter of 
> discussion (e.g. at first glance, `destroy()` can be fixed).
And another undocumented limitation for threaded Tcl: when calling 
anything from outside the interpreter thread, `mainloop()` must be 
running in the interpreter threads, or the call will either raise or 
hang (dunno any more details atm).
> ===

>> Tkinter was intended to also be thread-safe when using tcl/tk without 
>> thread support, which was the default for tcl/tk 8.5 and before. The 
>> posted examples can fail on 2.x on Windows, which comes with tcl/tk 
>> 8.5 or before. _tkinter.c has some different #ifdefs for the two 
>> situations.
>>> and yet it is documented as being thread safe
>> True in https://docs.python.org/3/library/tk.html
>> Unspecified in https://docs.python.org/3/library/tkinter.html
>>> This is either a bug(s) in the implementation or the docs.
>> Both
>>> So what are the solutions?
>>> 1) fix the docs -- unless tkInter is made thread safe really soon, 
>>> and fixes are back-ported, this seems like a no brainer -- at least 
>>> temporarily.
>> https://bugs.python.org/issue33479 'Document tkinter and threads'
>>> 2) fix the issues that make tkInter not thread safe
>> with non-thread tcl/tk.
>> https://bugs.python.org/issue33257 has a patch that might improve the 
>> situation for one type of call.? Fixing everything might not be 
>> possible.? AFAIK, there are currently no tests of thread safety.