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 3548
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: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| |