Good Day All,
I finished writing the site blocker process and then i renamed the "py" file by appending "w", double clicked to run it yet the process did not show up in the task manager. I tried it a few times and yet nothing showed up. Mind you I am on Win 10 OS.
You have any suggestions to help fix this such that is shows up in the task manager as pythonw.exe process ?
If the process isn't showing up in the Task Manager, it's very likely that it's immediately quitting with an error. Even trivial changes to the code cause this to occur. Without the console showing output it's hard to tell what that error is. Try renaming the file back to filename.py and running it to see if an error is occurring.
Another possibility is that the script is completing so fast you don't have time to see it. Did it run instantaneously when it was named filename.py?
Related
My current (PyCharm based) debugging workflow is to run a program in debug mode. When I run into an error, I fix it, and restart the program from the beginning.
Is it possible to save re-running the healthy part of the program by moving the program back by one step, fix the issue, and continue the program?
Is there a general way to do this, and one specific for PyCharm?
[edit:]
this is related but not similar to Is there "Edit and Continue" in PyCharm? Reload code into running program like in Eclipse / PyDev? , as there the author anticipates halts the program before an error occurs. here, i consider an error state
If I have a long running process that is running from file.py, can I edit file.py while it is running and run it again, starting a new process and not affect the already running process?
Yes, Python is not constantly reading the file, the file is only interpreted once per run. The current instance that is already running will not be affected by changes in the script.
Of course you can.
When you are running the first process, the unmodified code is loaded into memory,like a copy in memory. When you edit the running code, it makes another copy into memory, you won't change the original one.
And even though you click save, it won't make any change to the code in the memory that the first process is using.
But as you say, your program is very long. If you change a package the program hasn't used, it may cause the problem, coz the import part is loaded when the program execute the import part.
Basically it's all in the title, when I run the code from a console (on Windows) the child process runs without opening another console, but when I run the code from the cx_freeze'd app another console opens.
I found this old thread where was suggested to use FreeConsole(), it will flash the console on screen for a blink but I can eventually live with it, unfortunately if i understood correctly it should be called from the child process.
http://twistedmatrix.com/pipermail/twisted-python/2007-February/014738.html
I also found this ticket (7yo) on a re-factoring of the whole spawnProcess on windows but apparently it never happened:
http://twistedmatrix.com/trac/ticket/2415
I have no control over the code of the child process, so doing something there is unfortunately not an option, but even if I did the process I'm spawning it's a console app and I believe FreeConsole() could not be called there or the process will terminate.
This is possibly a bug in Twisted, but possibly a bug in cx_Freeze.
What happens when you run the code from the GUI with Python, but without cx_Freeze involved? You should be able to test this if you have Python installed by simply putting your code into a .pyw file and double-clicking on it in Explorer.
If this still pops up a console window when you run your subprocess, then this is totally a bug in Twisted and you should file it as such. Eric's answer in that mailing list message is wrong; if you want to spawn processes with spawnProcess they definitely shouldn't be popping up random console windows.
If the click-on-a-.pyw launching method doesn't cause a console window to pop up, then it's probably something about the way cx_Freeze has constructed your executable and you might want to look at it.
On UNIX, we have a platform-specific usePTY, so it makes sense that we could expand spawnProcess with a platform-specific useConsole that would do something analogous for Windows. This later message in the thread suggests an implementation strategy, so please file a ticket. The let's-redo-everything ticket is too ambitious to fix this one issue.
I wrote a small multiprocessing application and then wrote a PyQt front end for it. When I run the script by calling it from the command line with Python (or by calling run from the Spyder IDE), it runs exactly as I would expect and works nicely.
But if I try to use Py2Exe to make an executable to give it to a friend, it starts behaving oddly. When the users hits the botton that really starts the process and invokes the multithreading portion, it spawns multiple Qt windows that look like the original. It then essentially locks up. Closing one of the new windows that it spawns causes it to reopen that window. Attempting to close the original generates a message that it is not responding.
I would appreciate any help or suggestions about where to look.
I'm not positive about this without looking at your code, but there are some extra considerations when using Py2Exe with multithreading.
Take a look at this link and maybe it has something to do with your problem.
Someone has a similar sounding issue here
I can't seem to find the right google search to figure out something that should be easy.
I am using wxPython to create a GUI, and saving the Python files as .pyw so I don't have a console. Then I am importing another .py file into the main window when a user does an action. Doing so created the pythonw.exe instance that won't close. To be clear, the .pyw that opens if I only open the main console will clear from my processes if I don't open/insert the other .py file from the first file while running.
When I use the program everything is perfectly fine, but when I use the Windows "X" button to close I still get pythonw.exe in my processes, and the file I am printing errors to is locked due to something else using it(the pythonw.exe). What code do I need to use to make sure that python is exiting completely? It also seems to stay whenever I build in a file - exit as well, and it is only staying on the processes if I insert the other module(only done with user input)
Also this may be obvious but if I open the imported file manually it has the same behavior, as in the python.exe closes when I close out of the file.
If you want to exit the application you can do this like this:
import os
os._exit(0)
This works when the normal exit() or reaching the end of the main file does not work becaus of background threads running.
But so you are ending killing all running threads. You should look into the code of the imported file which causes the problem to see if it has threads.