Re: using timers to force an execution time

2009-07-16 Thread superpollo
Nick Craig-Wood wrote: > ... import signal, os, time ... importing os is useless of course... -- http://mail.python.org/mailman/listinfo/python-list

Re: using timers to force an execution time

2009-07-16 Thread superpollo
Nick Craig-Wood wrote: superpollo wrote: > ... Or if you are on unix you can use signals... It is probably just about acceptable to raise an exception in a signal handler like this code does. > ... neat! -- http://mail.python.org/mailman/listinfo/python-list

Re: using timers to force an execution time

2009-07-16 Thread Paul Moore
2009/7/16 superpollo : > hello. > > based upon previuos suggestions, i tried to write a program in which i would > like to have a certain code fragment to execute only for a specified amount > of time (say 3 seconds), then bail out. > > but i get the following: > > $ cat tmr004.py > #!/usr/bin/pyth

Re: using timers to force an execution time

2009-07-16 Thread Nick Craig-Wood
superpollo wrote: > Diez B. Roggisch wrote: > > superpollo wrote: > >>am i wrong? > > > > > > No, you are right, for threads that is. You can try & trick around with the > > trace-functionality of python, and some ctypes-based > > system-thread-module-tricks that are, as mentioned before, black

Re: using timers to force an execution time

2009-07-16 Thread superpollo
Diez B. Roggisch wrote: superpollo wrote: am i wrong? No, you are right, for threads that is. You can try & trick around with the trace-functionality of python, and some ctypes-based system-thread-module-tricks that are, as mentioned before, black-magic & a spinning gatling gun pointed to you

Re: using timers to force an execution time

2009-07-16 Thread Diez B. Roggisch
superpollo wrote: > Diez B. Roggisch wrote: >> superpollo wrote: >>>see? the while body ran for about 7 seconds... i bet it has to do with >>>the fact that the timer does not control inner loops... any suggestion? >> >> >> Of course the inner loop isn't affected by the set event - how should it

Re: using timers to force an execution time

2009-07-16 Thread superpollo
Diez B. Roggisch wrote: superpollo wrote: see? the while body ran for about 7 seconds... i bet it has to do with the fact that the timer does not control inner loops... any suggestion? Of course the inner loop isn't affected by the set event - how should it be, if you don't check it. if you

Re: using timers to force an execution time

2009-07-16 Thread Diez B. Roggisch
Diez B. Roggisch wrote: > superpollo wrote: > >> hello. >> >> based upon previuos suggestions, i tried to write a program in which i >> would like to have a certain code fragment to execute only for a >> specified amount of time (say 3 seconds), then bail out. >> >> but i get the following: >>

Re: using timers to force an execution time

2009-07-16 Thread superpollo
Diez B. Roggisch wrote: What you can't achieve in python without major black magic hackery that is very dangerous is to terminate a thread while it is executing. Termination has to be co-operative. i see. thanks a lot. bye -- http://mail.python.org/mailman/listinfo/python-list

Re: using timers to force an execution time

2009-07-16 Thread Diez B. Roggisch
superpollo wrote: > hello. > > based upon previuos suggestions, i tried to write a program in which i > would like to have a certain code fragment to execute only for a > specified amount of time (say 3 seconds), then bail out. > > but i get the following: > > $ cat tmr004.py > #!/usr/bin/pytho

Re: using timers to force an execution time

2009-07-16 Thread Xavier Ho
On Thu, Jul 16, 2009 at 6:34 PM, superpollo wrote: > hello. > > based upon previuos suggestions, i tried to write a program in which i > would like to have a certain code fragment to execute only for a specified > amount of time (say 3 seconds), then bail out. > > > see? the while body ran for

using timers to force an execution time

2009-07-16 Thread superpollo
hello. based upon previuos suggestions, i tried to write a program in which i would like to have a certain code fragment to execute only for a specified amount of time (say 3 seconds), then bail out. but i get the following: $ cat tmr004.py #!/usr/bin/python -u import threading , time e =