Python and threads

vedrandekovic at yahoo.com vedrandekovic at yahoo.com
Sun Jan 18 14:38:51 EST 2009


On 18 sij, 17:48, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> vedrandeko... at yahoo.com schrieb:
>
>
>
> > Hello again,
>
> > Thanks for previous help on "Start two threads in same time" it was
> > useful,but when I run this
> > two threads, I think they don't start at the same time, here is my
> > code snippet:
>
> > import threading
>
> > class ThreadedClass1(threading.Thread):
> >     def __init__(self):
> >         threading.Thread.__init__(self)
>
> >     def run(self):
> >         a=True
> >         while a==True:
> >             bm=my_module.MyClass()
> >             a=bm.get_Python_Process_Usage_Function()   #Returns True
> > or False
>
> > class ThreadedClass2(threading.Thread):
> >     def __init__(self):
> >         threading.Thread.__init__(self)
>
> >     def run(self):
> >         os.popen("my_python_script.py")
>
> > threaded_obj = ThreadedClass1()
> > threaded_obj.start()
> > threaded_obj2 = ThreadedClass2()
> > threaded_obj2.start()
>
> If you want to synchronize two or more threads, you need to do so
> manually using objects like Locks, Events, Conditions and Semaphores.
> See the threading module.
>
> Even if you managed to get two threads started simultaneously (which the
>   OS doesn't even offer IINM), the would soon run out of sync.
>
> How about you tell us what you *want*, and we tell you if and how it's
> possible to do that.
>
> Diez

Hello,

and thanks for all previous help.I want to measure memory usage of
executed python script.I'am working on windows XP.

Regards,
John



More information about the Python-list mailing list