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

Debug cause of freezing leading to forced restart #1228

Closed
peetm opened this issue Oct 12, 2023 · 11 comments
Closed

Debug cause of freezing leading to forced restart #1228

peetm opened this issue Oct 12, 2023 · 11 comments

Comments

@peetm
Copy link

peetm commented Oct 12, 2023

Occasionally, I find that PyScripter will cease responding and lock-up, requiring a forced process termination.

This usually happens when querying objects' states via the REPL, possibly during debugging (but not sure, I will try and log exactly when in future). The locking-up appears to exhibit all of the classic signs on a threading, come fatal embrace. After terminating PyScripter, I also have to go and kill a running Python instance which will typically be consuming around 75% of the CPU.

What is the best method for assisting with the diagnosis of such hangs? Can a mechanism (even if it's simple logging) be added to assist in this?

By the way, this most recently happened on a new Windows 11 machine on which Python (3.11.2) and the latest (current) version of PyScripter was installed for teaching purposes. So, it's not just my Windows 10 machine.

@pyscripter
Copy link
Owner

This usually happens when querying objects' states via the REPL

This is related to #1212. Please wait for the new version that resolves this.

@pyscripter
Copy link
Owner

Please check out version 4.3 and provide feedback regarding this issue.

@peetm
Copy link
Author

peetm commented Oct 15, 2023 via email

@pyscripter
Copy link
Owner

You've a typo in your blog - says 4.2

Fixed. Thanks!

@Maxim4711
Copy link

Maxim4711 commented Mar 5, 2024

I am not sure, where this issue should be adressed, but it still hangs/freezes in my environment after certain imports. For instance, if i install oracledb with "pip install oracledb" and then have a file with content like

import os
import platform
# import oracledb

d = None  # default suitable for Linux
if platform.system() == "Darwin" and platform.machine() == "x86_64":   # macOS
  d = os.environ.get("HOME")+("/Downloads/instantclient_19_8")
elif platform.system() == "Windows":
  d = os.environ.get("ORACLE_HOME")
# oracledb.init_oracle_client(lib_dir=d)

def main():
    print(platform.system())
    print(d)

if __name__ == '__main__':
    main()

Then i can run it without any issue, but if i uncomment the line with "import oracledb" - it freezes and pyscripter needs to be restarted.
Pyscripter is 4.3.4.0 x64

@Maxim4711
Copy link

The mentioned behaviour occures only with remote engine, if i use internal engine instead - no hangs are observed

@Maxim4711
Copy link

I've tried to disable completely defender firewall - despite that the issue still persists with remote engine

@Maxim4711
Copy link

The regression happened somewhere after 4.2.5 - i tested 4.2.5 with Python 3.11.8 and no freezing happened. With 4.3.4 and Python 3.11.8 it hangs equally as with Python 3.12.2

@pyscripter
Copy link
Owner

pyscripter commented Mar 12, 2024

Thanks. I will investigate...

Is it just the oracledb module that is causing you trouble or you have problems with other modules?

@pyscripter
Copy link
Owner

pyscripter commented Mar 13, 2024

I found the reason for the freezing:
oracle db starts the following thread close_pools_gracefully which waits for the main thread to finish.

What was added to Pyscripter a few versions back is the following:

                    for t in threading.enumerate():
                        if (t != threading.main_thread()) and not t.daemon:
                            try:
                                t.join()
                            except:
                                pass

This is executed after running or debugging a script. As you can see the python main thread waits for the oracledb thread to finish and oracledb waits for the main thread to finish - hence the blockage.

Whilst I think it is bad design the way the oracledb thread waits for the main thread to finish, I will consider removing the PyScripter code that waits for non-deamon threads to finish or add a timeout parameter, so that it does not block forever.

In the meantime pressing the Abort button and then using the command Run, Python Engine, Reinitialize Python Engine, should work.

@pyscripter
Copy link
Owner

pyscripter commented Mar 14, 2024

@Maxim4711 Fixed in version control. The fix will be available with the next release.

In the meantime you can download the updated executable and test it. Just replace PyScripter.exe with the one in the zip file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants