Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please! let this throw an exception: Tcl_AsyncDelete: async handler deleted by the wrong thread #113770

Closed
schittli opened this issue Jan 6, 2024 · 3 comments
Labels
topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@schittli
Copy link

schittli commented Jan 6, 2024

Crash report

What happened?

Hello
thank you very much for your great and useful work.

I have a very common and small issue:

I one uses the Tk Backend (e.g. with Matplotlib), then it often happens (as google shows), that the Python Script crashes(!) and just displays:
Tcl_AsyncDelete: async handler deleted by the wrong thread

Unfortunately, this is the worst case, because we can not catch this bug: it just stops the Script and does not throw an Tcl_AsyncDelete 😞

So, please: if Python gets into an Tcl_AsyncDelete issue, then, please, trow an exception, so that the script can act on it!

Thanks a lot, kind regards,
Thomas

(It is a shame that the code handling Tcl_AsyncDelete was not developed as an exception from the beginning)

CPython versions tested on:

3.11

Operating systems tested on:

Windows

Output from running 'python -VV' on the command line:

Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]

@schittli schittli added the type-crash A hard crash of the interpreter, possibly with a core dump label Jan 6, 2024
@sunmy2019 sunmy2019 changed the title Please!, let this throw an exception: Tcl_AsyncDelete: async handler deleted by the wrong thread Please! let this throw an exception: Tcl_AsyncDelete: async handler deleted by the wrong thread Jan 6, 2024
@vaishnavi192
Copy link
Contributor

hey @schittli I want to work on this issue...I think
try:
# Tkinter code here
except TclError as e:
# Tcl_AsyncDelete exception here something like using try and except will solve this issue. can you plz guide in which file I have to make changes?

@ronaldoussoren
Copy link
Contributor

This is probably a duplicate of #83274, likely triggered by running Tk code in a secondary thread.

From what I've read on this (as a non-Tk expert), the error is an assertion in error in the Tcl implementation, and not something we can catch in the Tkinter implementation to convert to a Python exception. The issue I link to contain some information on how to change the Tkinter implementation to (mostly?) ensure that Tcl objects are destroyed in the correct thread.

@serhiy-storchaka
Copy link
Member

Agree, it is a duplicate of #83274 which is a very complex issue.

@serhiy-storchaka serhiy-storchaka closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

6 participants
@ronaldoussoren @serhiy-storchaka @schittli @AlexWaygood @vaishnavi192 and others