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 3592
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: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |