two silly questions

B

bill ramsay

Hello

just found the wonderful world of python in the last two weeks and I
think that it is great.

I have a couple of questions for those who are wiser a la python than
I am.

Background:

I have written a program that polls an email account, then pulls down
the email, it then searches through the email, and depending upon
type, ie. with or without attachments it does different things. The
net result is that data is written to access tables for an external
application to extract the necessary data.

I am using win2k.

the two questions are:

1. when i want the program to run in a loop, ie. poll the pop3
account every 60 seconds, it runs the first time, then it goes into
'not responding mode' thereafter, sometimes. Any thoughts? I was
using sleep(60) but it just hangs, as i said before, it does not
always do that either!

2. I wish to use this program at work, I took in an earlier version
yesterday that just wrote the data to a text file, I wanted to make
sure the polling thing worked. on microsoft exchange [i know that it
should, but you never know!!] and it does . When i was there, i
managed to get the code to run just by double clicking on the code
ICON, seem to remember doing something with 'open with' can't seem to
do it here at home.

Both systems run win2k. did i do something sublimilally without
realising it? what did i do i cannot remember, i have tried opening
with etc. when i do this all get is a burst of the 'black windows
box' just in the same way as putting in 'cmd' on the run thing,

as you can see i am not up on all the terms.

if anyone can help, i would appreciate it.

kind regards

bill ramsay.
 
M

Miki Tebeka

Hello Bill,
1. when i want the program to run in a loop, ie. poll the pop3
account every 60 seconds, it runs the first time, then it goes into
'not responding mode' thereafter, sometimes. Any thoughts? I was
using sleep(60) but it just hangs, as i said before, it does not
always do that either!
Do you mean it sometime hang? IMO it point to a bug in your code.
Try adding a lot of "print 'I am here'" in your code and reduce the
sleep time to 0.1 and run. See where you get stuck.
2. I wish to use this program at work, I took in an earlier version
yesterday that just wrote the data to a text file, I wanted to make
sure the polling thing worked. on microsoft exchange [i know that it
should, but you never know!!] and it does . When i was there, i
managed to get the code to run just by double clicking on the code
ICON, seem to remember doing something with 'open with' can't seem to
do it here at home.
The standard Python installer associates .py with python so when you
click on a .py file (or call it from the command line) it runs the
Python interpreter on it.

If you don't want to see the "black window" rename the extension to
..pyw, this way pythonw.exe will run the script and won't produce any
console. OTOH it means you won't see any printing what so ever so make
sure you log *everything*.

HTH.
Bye.
 
L

Larry Bates

The absolute "best" way to do what you want is to write
an NT service. Mark Hammond's Python Programming on
Win32 has excellent examples of this. NT services
run in the background and can be set to actually sleep
for any amount of time (in microseconds). I've written
several of these and while the learning curve is a
little steep on the front end, the resulting application
is MUCH better.

HTH,
Larry Bates
Syscon, Inc.
 
B

bill ramsay

The absolute "best" way to do what you want is to write
an NT service. Mark Hammond's Python Programming on
Win32 has excellent examples of this. NT services
run in the background and can be set to actually sleep
for any amount of time (in microseconds). I've written
several of these and while the learning curve is a
little steep on the front end, the resulting application
is MUCH better.

thanks for this, much appreciated, funnily enough i had a sniff in
there today, and i think i found what you are reffering to.

kind regards

bill ramsay


HTH,
Larry Bates
Syscon, Inc.

bill ramsay said:
Hello

just found the wonderful world of python in the last two weeks and I
think that it is great.

I have a couple of questions for those who are wiser a la python than
I am.

Background:

I have written a program that polls an email account, then pulls down
the email, it then searches through the email, and depending upon
type, ie. with or without attachments it does different things. The
net result is that data is written to access tables for an external
application to extract the necessary data.

I am using win2k.

the two questions are:

1. when i want the program to run in a loop, ie. poll the pop3
account every 60 seconds, it runs the first time, then it goes into
'not responding mode' thereafter, sometimes. Any thoughts? I was
using sleep(60) but it just hangs, as i said before, it does not
always do that either!

2. I wish to use this program at work, I took in an earlier version
yesterday that just wrote the data to a text file, I wanted to make
sure the polling thing worked. on microsoft exchange [i know that it
should, but you never know!!] and it does . When i was there, i
managed to get the code to run just by double clicking on the code
ICON, seem to remember doing something with 'open with' can't seem to
do it here at home.

Both systems run win2k. did i do something sublimilally without
realising it? what did i do i cannot remember, i have tried opening
with etc. when i do this all get is a burst of the 'black windows
box' just in the same way as putting in 'cmd' on the run thing,

as you can see i am not up on all the terms.

if anyone can help, i would appreciate it.

kind regards

bill ramsay.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top