question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deadlock while closing the window with persistent threads running

See original GitHub issue

When updating the DOM from a separate thread, using calls like webview.evaluate_js() I found it quite useful to have an API call which indicates whether the window is still present / attempting to close.

Problem

If one clicks the close button on a window (rather than quitting it like with Apple + Q), and then a separate thread calls to the webview object, like webview.evaluate_js(), this thread becomes blocked and stuck in that call indefinitely.

What would be helpful is a function like webview.window_exists()

which returns a boolean, which is set within WindowDelegate::windowWillClose_() (and the equivalent location on other platforms). I tested this by adding a global variable to cocoa.py which is set within windowWillClose_, and having webview return the status of this boolean. Certainly not the cleanest way, but it works.

Could we perhaps integrate this in a more OO-friendly fashion. I’m happy to help.

Alternatively, we could provide an API for a callback function, which would be called (in addition to the window closing) when the user hits the “x” or close button on a window. A sort-of cleanup call, to prevent deadlock.

Thoughts? Thanks! Michael

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
r0x0rcommented, Nov 15, 2017

@shivaprsdv Looks good. Would you make a PR?

1reaction
pomplesiegelcommented, Nov 7, 2017

Hello @shivaprsdv, sorry for the delay! I have tested both branches and am currently running the deadlock-fix-alt branch in my program. It’s behaving very well! I have tested on both mac and windows. I will continue testing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve deadlocks in SQL Server - SQLShack
First of all, let's explain the deadlock concept. A deadlock problem occurs when two (or more than two) operations already want to access ......
Read more >
Operating Systems: Deadlocks
A set of processes is deadlocked when every process in the set is waiting for a resource that is currently allocated to another...
Read more >
Why would fclose hang / deadlock? (Windows) - Stack Overflow
After running for a while, the directory monitor process hangs on a call to fclose() in a method that is basically tailing the...
Read more >
Debugging a Deadlock - Windows drivers | Microsoft Learn
A deadlock arises when two or more threads have requested locks on two or more resources, in an incompatible sequence. For instance, suppose ......
Read more >
Flow Control, Threads and Deadlock
When using flow control, you must be careful to avoid potential deadlock. When flow control is in effect for a destination, producers to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found