I’m making a pywinauto program to automate tasks in a benchmarking program. It will not work with the ‘win32’ backend because it has some special control-types, thus I have stuck with ‘uia’. For the past few weeks, the program has worked somewhat fine with few pywinauto bugs. However, I have noticed that over time, starting the program over and over (due to debugging and the occasional error), it will suddenly slow down for about 1-2 minutes per operation until I restart my computer.
More specifically, when this happens, every pywinauto searching operation slows down significantly. For example, calling dialog.child_window()
begins to take almost exactly 60 seconds each time it is called (with and without timeouts). I’ve read up on the ways to speed it up, such as control-type, class-name, and wrapper objects, but this has not changed the speed at all since I had already been doing this in my code. The application itself has <200 identifiers, so I don’t believe it’s a size issue either.
To re-iterate, this would only happen after I’ve been debugging the program for many hours and it failed to close the app after so many times. Restarting my computer has been a working solution up until now. As of recent, it is always slow per every search (child_window) operation, even after a restart. Before, the entire program would complete its automation in about 15-20 seconds. Now, it takes almost 15-20 minutes.
Finally, I am unsure whether it has to do with how I connect to the application, but I believe this may not be the cause of my problems as this same line worked fine a week ago.
myApp = Application(backend='uia', allow_magic_lookup=False).connect(title="Benchmark - GUI 1.2.1", timeout=45)
This line takes about 60 seconds to connect to my window, regardless of what the timeout time is. I have also tried starting the application, then connecting to it, with no difference in time. Subsequently, every line that has to find an identifier will take a similar amount of time.
This problem really has me stumped since it worked perfectly fine for the past few weeks, so sorry if this post is ramble-y haha. I’ve skimmed through a handful of the github posts, but I haven’t come across one that has a solution that has worked for me. One thing I did notice when reinstalled was the clear_comtypes_cache package giving a warning about its directory not being in PATH, but again I am unsure if this is the cause or at all related.
Here are the solutions I have tried:
- adding specifics to child_window() such as control_type, title, top_level_only, etc
- restarting my computer each time this occurs (doesn’t work anymore)
- reverting windows updates to before this problem was prominent
- similarly, checking for windows updates
- reinstalling pywinauto
- wrapper objects to hold objects used many times
- buffering when the app starts and when it connects
- attempting to automate a different application to see if it’s app specific
- clearing caches
As stated, restarting my computer was a solution up until now. As of now, I have restarted my computer a handful of times and the problem still persists. Next, when it slows, using wrapper objects reduces the time to about 1 minute per operation. Every other attempt hasn’t gotten me anywhere.
I hope I have provided sufficient information about what I have tried and what my problem is. I will gladly provide more information as needed. Any input, suggestions, ways I could troubleshoot would greatly be appreciated. Thanks! 🙂
jumpy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.