Hello,
I am running WinXP SP2 with Python 2.5.1 and encountered the following
issue:
I wrote a script that logs into my mail server, and checks for new
messages every 20 seconds. When a new message is found, it displays a
Windows tool tip and prints a line to console indicating a new
message.
When I run the script with python.exe (console), the script runs fine
and checks for new messages in perpetuity (as it should). However,
when I run the script with pythonw.exe (no console), the script
prematurely exits after 10 or 15 minutes. For those 15 minutes, it
works as it should, displaying tool tips when new messages arrive.
Furthermore, when it exits prematurely, it appears to be exiting
gracefully (I have an exit routine that logs out of the mail server
and cleans up).
Does anyone know why this might be the case? The lines printed to
console are purely for diagnostic purposes. Otherwise, the two
processes should be identical.
Thanks!
Brian 3 3574
I am running WinXP SP2 with Python 2.5.1 and encountered the following
issue:
I wrote a script that logs into my mail server, and checks for new
messages every 20 seconds. When a new message is found, it displays a
Windows tool tip and prints a line to console indicating a new
message.
When I run the script with python.exe (console), the script runs fine
and checks for new messages in perpetuity (as it should). However,
when I run the script with pythonw.exe (no console), the script
prematurely exits after 10 or 15 minutes. For those 15 minutes, it
works as it should, displaying tool tips when new messages arrive.
Furthermore, when it exits prematurely, it appears to be exiting
gracefully (I have an exit routine that logs out of the mail server
and cleans up).
Does anyone know why this might be the case? The lines printed to
console are purely for diagnostic purposes. Otherwise, the two
processes should be identical.
You say it exits gracefully, I'm not sure I know what you mean. My
guess is that you are writing to stdout, and when the buffer fills up
and tries to dump the program exits with an exception (but returns
0).
I've run into something similar before, you can reproduce it with
this: -
import sys
-
-
f2 = open("bo.err", "w")
-
sys.stderr = f2
-
for i in range(10000):
-
print i
-
Run with pythonw then look at "bo.err" to see the exception.
You can either stop printing to stdout and send the stuff somewhere
else (maybe use the logging module), or you can assign stdout and
stderr to nul. -
import sys
-
import os
-
-
nul = open(sys.devnull,'w')
-
sys.stdout = nul
-
sys.stderr = nul
-
-
# The rest of your code
-
Matt
Hi Matt,
Your reply is much appreciated.
So let me see if I understand. When console is running, it dumps
stdout to console, the buffer is flushed regularly, and everything is
fine and dandy. But when running without console, the stdout buffer
fills up because it has no physical handle to dump to, an exception is
thrown, and the process bails.
The graceful exit I mentioned before (the cleanup routine) was likely
due to a try/except I wrapped around the polling loop that handled the
exception you described.
I'll give it a try. Thanks!
Brian
On Oct 23, 4:43 pm, Matimus <mccre...@gmail.comwrote:
I am running WinXP SP2 with Python 2.5.1 and encountered the following
issue:
I wrote a script that logs into my mail server, and checks for new
messages every 20 seconds. When a new message is found, it displays a
Windows tool tip and prints a line to console indicating a new
message.
When I run the script with python.exe (console), the script runs fine
and checks for new messages in perpetuity (as it should). However,
when I run the script with pythonw.exe (no console), the script
prematurely exits after 10 or 15 minutes. For those 15 minutes, it
works as it should, displaying tool tips when new messages arrive.
Furthermore, when it exits prematurely, it appears to be exiting
gracefully (I have an exit routine that logs out of the mail server
and cleans up).
Does anyone know why this might be the case? The lines printed to
console are purely for diagnostic purposes. Otherwise, the two
processes should be identical.
You say it exits gracefully, I'm not sure I know what you mean. My
guess is that you are writing to stdout, and when the buffer fills up
and tries to dump the program exits with an exception (but returns
0).
I've run into something similar before, you can reproduce it with
this: -
import sys
-
f2 = open("bo.err", "w")
-
sys.stderr = f2
-
for i in range(10000):
-
print i
-
Run with pythonw then look at "bo.err" to see the exception.
You can either stop printing to stdout and send the stuff somewhere
else (maybe use the logging module), or you can assign stdout and
stderr to nul.
-
import sys
-
import os
-
nul = open(sys.devnull,'w')
-
sys.stdout = nul
-
sys.stderr = nul
-
# The rest of your code
-
Matt
The script has been running console-free for about an hour now without
bailing. Looks like it was the stdout buffer.
Thanks!
Brian
On Oct 23, 4:43 pm, Matimus <mccre...@gmail.comwrote:
I am running WinXP SP2 with Python 2.5.1 and encountered the following
issue:
I wrote a script that logs into my mail server, and checks for new
messages every 20 seconds. When a new message is found, it displays a
Windows tool tip and prints a line to console indicating a new
message.
When I run the script with python.exe (console), the script runs fine
and checks for new messages in perpetuity (as it should). However,
when I run the script with pythonw.exe (no console), the script
prematurely exits after 10 or 15 minutes. For those 15 minutes, it
works as it should, displaying tool tips when new messages arrive.
Furthermore, when it exits prematurely, it appears to be exiting
gracefully (I have an exit routine that logs out of the mail server
and cleans up).
Does anyone know why this might be the case? The lines printed to
console are purely for diagnostic purposes. Otherwise, the two
processes should be identical.
You say it exits gracefully, I'm not sure I know what you mean. My
guess is that you are writing to stdout, and when the buffer fills up
and tries to dump the program exits with an exception (but returns
0).
I've run into something similar before, you can reproduce it with
this: -
import sys
-
f2 = open("bo.err", "w")
-
sys.stderr = f2
-
for i in range(10000):
-
print i
-
Run with pythonw then look at "bo.err" to see the exception.
You can either stop printing to stdout and send the stuff somewhere
else (maybe use the logging module), or you can assign stdout and
stderr to nul.
-
import sys
-
import os
-
nul = open(sys.devnull,'w')
-
sys.stdout = nul
-
sys.stderr = nul
-
# The rest of your code
-
Matt
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ..:: sjf ::.. |
last post by:
Hi,
When I'm running IDLE (on Windows) a great number of pythonw.exe process
exists in the Task Manager. What is to cause it?
--
...:: sjf ::..
"Linux is like Wigwam. No gates, no...
|
by: Eric Ching |
last post by:
Can I run pythonw with a script that takes command line arguments then
launches a GUI? I try pythonw myscript.pyw -option arg (etc.) and
nothing happens. Nothing, as in I am immediately returned...
|
by: vm_usenet |
last post by:
Hi everyone,
I've seen this subject come up in another thread, but not getting
enough attention - so I'll just ask it:
When running python code via pythonw, what exactly happens to stderr?
I...
|
by: Robin Becker |
last post by:
There seems to be a problem with calling subprocesses from a script run
with pythonw rather than python. The error doesn't seem to be a function
of using pythonw.exe rather than python.exe in the...
|
by: Jo Schambach |
last post by:
I wrote a python GUI with tkInter and installed it on a windows machine
with the .pyw extension, so it will be executed from pythonw.exe instead
of python.exe, since I didn't want the console...
|
by: Randy Harris |
last post by:
I've been fighting a problem with A2K for weeks now and am absolutely
stumped. I have a procedure that is called from the Activate event of a
form. The procedure creates a couple of recordsets,...
|
by: Roger Miller |
last post by:
I was going to ask how to a program can tell whether it was started by
python.exe or pythonw.exe, but after some experimentation I noticed
that sys.stdin.fileno() is -1 in the latter case.
...
|
by: Ron Garret |
last post by:
I'm trying to run the Python examples distributed with XCode and they
all give me the same error:
Traceback (most recent call last):
File "checktext.py", line 35, in <module>
main()
File...
|
by: John Velman |
last post by:
New to mac. I have leopard. What's the difference between python and
pythonw? So far (which isn't very far) I can't tell the difference.
I have a small application using TKinter that I was...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |