-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Console loggin problem when using pywinauto with pytest #7059
Comments
Just for reference: this looks related to a crash seen on CI here lately (#7022). /cc @bluetech From the gist:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@aaltat Thanks for the detailed report! We are seeing something similar in pytest CI, which may or may not be related. What I'd be interested in finding out first is whether this is caused by something pytest does, or if it can be reproduced without it. What the faulthandler plugin does, when not running under import faulthandler, os, sys
print("BEFORE enable")
stderr_fd_copy = os.dup(sys.stderr.fileno())
faulthandler.enable(file=stderr_fd_copy)
print("AFTER enable")
# Tests run here.
print("BEFORE disable")
faulthandler.disable()
os.close(stderr_fd_copy)
print("AFTER disable") (I added some printf debugging) So I wonder what happens if you run the above directly (without pytest), inserting the |
I did have this code: import subprocess
import time
import pywinauto
import faulthandler, os, sys
print("BEFORE enable")
stderr_fd_copy = os.dup(sys.stderr.fileno())
faulthandler.enable(file=stderr_fd_copy)
print("AFTER enable")
subprocess.Popen(r'C:/Program Files/Notepad++/notepad++.exe')
app = pywinauto.Application(backend='uia')
win = None
count = 0
while win is None:
try:
app.connect(title_re='new ')
win = app.window()
except pywinauto.ElementNotFoundError:
if count > 5:
raise
time.sleep(1)
finally:
count += 1
win.print_control_identifiers(filename=r'C:/tmp/print_control_identifiers_1212.log')
print("BEFORE disable")
faulthandler.disable()
os.close(stderr_fd_copy)
print("AFTER disable")
And then the output looked like this (this time made sure that CMD buffer does not get full before I could copy the output):
Please tell if I can help in debugging the problem further. |
This looks like a crash in native code. The I am not sure why the same stack trace is endlessly repeated. It should only be dumped once. It is not clear the output In any case, my suggestion is to report this issue with your reproduction code to the pywinauto library, they might be of more help. I don't think this is related to pytest. Most you can do is use |
I encountered the same problems, error messages are the same, but with administrator privileges to run Python scripts, there is no error message |
Hi, Is this issue solved? Please help. |
For me the problem can be avoided by running tests without faulthandler, example |
That worked for me as well. Thanks for the prompt response! |
I have strange console output problem if I have test that uses pytest and pywinauto. The problem can reproduced also by using uiautomation. I think the common underlying nominator is comtypes, but that is just guessing and I lack the skills to confirm that assumption.
The example test in below needs pywinauto and Notepad++ installed with
new 1
tab active in the Notepad++ UI:When I run this test (In Windows 10, 1909 64bit) using Python 3.8.2:
python -m pytest test_pywinauto.py
then I see endless output in the cmd, see Github gits for part of the log. It looks like test does not end and logging is in some sort of endless loop. I did try pytest versions 5.4.1, 5.2.2, 5.0.1, 5.0.0 and 4.6.9 to see where the problem starts. All of the 5.x series had a similar problem but the 4.6.9 did not suffer from the same problem and test did execute without problems.
Then did do git bisect to try to trace the problem to a specific commit and after few good/bad commands, I did end up seeing this:
Now if I run the above test with command (with pytest 5.4.1):
python -m pytest -p no:faulthandler test_pywinauto.py
console output problem is not present and test is executed successfully:
Although there is a workaround available, it would be nice to understand why commit a37b902 causes such problem. This also could be in some way related to #5743 because when faulthandler is disabled, the console does not anymore contain lines saying:
Windows fatal exception:...
.My
pip list
looks like:The text was updated successfully, but these errors were encountered: