From: Alex Hall on
Hi all,
I have a program with a timer in it, therefore I have multiple
threads. My method of exiting by using "user32.PostQuitMessage (0)" no
longer seems to be doing the job since I added the timer. What else do
I have to do to close my program? I say it is not closing because,
before, I would be returned to a prompt in the cmd line, but now I
cannot type in the cmd line window even after the program supposedly
closes, whereas before I could have. Thanks.

--
Have a great day,
Alex (msg sent from GMail website)
mehgcap(a)gmail.com; http://www.facebook.com/mehgcap
From: Tim Golden on
On 24/03/2010 10:43, Alex Hall wrote:
> Hi all,
> I have a program with a timer in it, therefore I have multiple
> threads. My method of exiting by using "user32.PostQuitMessage (0)" no
> longer seems to be doing the job since I added the timer. What else do
> I have to do to close my program? I say it is not closing because,
> before, I would be returned to a prompt in the cmd line, but now I
> cannot type in the cmd line window even after the program supposedly
> closes, whereas before I could have. Thanks.
>

Make the timer thread a daemon?

TJG
From: Alf P. Steinbach on
* Alex Hall:
> Hi all,
> I have a program with a timer in it, therefore I have multiple
> threads.

Is the "therefore..." an inference or independendent information?

If it is an inference then it may not be correct.

For example, timers in a GUI program need not involve additional threads.


> My method of exiting by using "user32.PostQuitMessage (0)"

This sounds like the Windows API level accessed from Python, not Python level?

At the Windows API level, as I recall PostQuitMessage results in a WM_QUIT
posted to the current thread's message queue, where it'll be processed by this
thread's message loop, if it has one, which will then ideally finish.

Possibly, if you indeed have more than one thread, you're posting the WM_QUIT to
the wrong thread -- to quit the app it needs to be posted to the main thread.


> no
> longer seems to be doing the job since I added the timer. What else do
> I have to do to close my program? I say it is not closing because,
> before, I would be returned to a prompt in the cmd line, but now I
> cannot type in the cmd line window even after the program supposedly
> closes, whereas before I could have. Thanks.

Try to reduce the problem to a minimal complete program, and post that?

Unless the above comments help?


Cheers,

- Alf
From: Alex Hall on
A daemon... Good idea, and that makes more sense for what the thread
does anyway; it is just a timer, updating a variable by contacting a
server every hour. By the way, just what is the difference between
user32.PostQuitMessage (0) and sys.exit()?


On 3/24/10, Tim Golden <mail(a)timgolden.me.uk> wrote:
> On 24/03/2010 10:43, Alex Hall wrote:
>> Hi all,
>> I have a program with a timer in it, therefore I have multiple
>> threads. My method of exiting by using "user32.PostQuitMessage (0)" no
>> longer seems to be doing the job since I added the timer. What else do
>> I have to do to close my program? I say it is not closing because,
>> before, I would be returned to a prompt in the cmd line, but now I
>> cannot type in the cmd line window even after the program supposedly
>> closes, whereas before I could have. Thanks.
>>
>
> Make the timer thread a daemon?
>
> TJG
> --
> http://mail.python.org/mailman/listinfo/python-list
>


--
Have a great day,
Alex (msg sent from GMail website)
mehgcap(a)gmail.com; http://www.facebook.com/mehgcap
From: Tim Golden on
On 24/03/2010 11:04, Alex Hall wrote:
> A daemon... Good idea, and that makes more sense for what the thread
> does anyway; it is just a timer, updating a variable by contacting a
> server every hour. By the way, just what is the difference between
> user32.PostQuitMessage (0) and sys.exit()?

The former is a notification to a Windows message loop (something
most Python programs don't have) that it should exit; the latter
is a system call to exit the running program -- after any message
loops have completed if applicable.

BTW if you're running a Windows message loop anyway, you could just
use Windows timers, catch the WM_TIMER message and avoid the complication
of threads. Just an idea.

TJG