This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tkinter lock conflicts extension widgets
Type: enhancement Stage: test needed
Components: Tkinter Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, asvetlov, gpolo, jyrkialakuijala, loewis
Priority: normal Keywords:

Created on 2002-04-05 18:13 by jyrkialakuijala, last changed 2022-04-10 16:05 by admin.

Messages (7)
msg61084 - (view) Author: Jyrki Alakuijala (jyrkialakuijala) Date: 2002-04-05 18:13
I need to access the thread lock in the _tkinter.c.

I have the following callgraph:
1) Python code
2) Tcl/Tk event loop (tkinter mainloop->)
3) Mouse callback to my own Tk extension widget
4) A lot of C++ stuff, which is also called directly
   from python
5) Python
6) Calling tk (which crashes due to the tk lock)

It is be possible to avoid this by creating a
tcl event with a python callback instead of calling
c++ from the tk extension widget. However, in a
painting program this is not ok for performance.
The real time capabilities of Python are pretty
bad and mouse movement becomes stopped for a few
milliseconds every now and then, leaving significant
discontinuities in the mouse tracking.

I have been able to have excellent behavior by
exposing the thread lock of _tkinter.c and release
the tk-lock when the call from the widget enters
the C++ side and lock it again when the C++ side
returns.

However, this is not possible with the standard
_tkinter.c, because the lock is a static member.
There are two possible solutions that would fix
my problems:

1) real-time python mode, that allows for turning
off GC and all other possible delays in the
interpreter. Then I could use the python for
managing tk events without mouse jumps.

2) exposing the thread lock with a simple api that
allows the use of LEAVE_TCL and ENTER_TCL outside
_tkinter.

The 2) is simpler. It consists of removing a keyword
"static" in _tkinter.c, while real-time python
is probably a 3.0 thing? Thus I would vote for a
fix in _tkinter.c for allowing me not to compile
my own python.
msg61085 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-06-09 17:18
Logged In: YES 
user_id=21627

Just removing the static on the lock is not sufficient, if
_tkinter.so is a shared library. Instead, providing a
CObject in _tkinter would help.

Would you like to produce a patch for that?
msg81812 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-12 20:00
No reply from OP, will close unless someone argues against it.
msg81814 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-02-12 20:10
Why close ? It is still a valid feature request (with no patch yet).
msg81815 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-12 20:29
Leaving open, then :)

Thanks!
msg114179 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-17 21:56
@Guilherme I'm guessing that you're still interested in this, yes?
msg114182 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2010-08-17 22:05
> @Guilherme I'm guessing that you're still interested in this, yes?

I don't see the point in closing an issue simple because no one
responded. I think the question to be asked is more towards "is it
solved?" than "are you interested on it?". If the issue is invalid
considering all the changes that happened since the initial message
then I'm in favor in closing it.
History
Date User Action Args
2022-04-10 16:05:11adminsetgithub: 36387
2014-02-03 19:13:24BreamoreBoysetnosy: - BreamoreBoy
2012-03-26 19:22:28asvetlovsetversions: + Python 3.3, - Python 2.7
2012-03-26 19:22:17asvetlovsetnosy: + asvetlov
2010-08-17 22:05:46gpolosetmessages: + msg114182
2010-08-17 21:56:03BreamoreBoysetnosy: + BreamoreBoy
messages: + msg114179
2009-02-12 20:29:11ajaksu2setmessages: + msg81815
2009-02-12 20:10:40gpolosetnosy: + gpolo
messages: + msg81814
2009-02-12 20:00:32ajaksu2setnosy: + ajaksu2
stage: test needed
messages: + msg81812
versions: + Python 2.7
2002-04-05 18:13:48jyrkialakuijalacreate