En Mon, 12 Oct 2009 14:52:42 -0300, VYAS ASHISH M-NTB837
escribió:
The function that I want to run is part of a class, not a standalone
function. There are several class member variables also.
What about modifying the run() method so it runs more than once? Perhaps
using a Queue object to
VYAS ASHISH M-NTB837 schrieb:
>
> The function that I want to run is part of a class, not a standalone
> function. There are several class member variables also.
Then try:
class MyClass(object):
...
def run(self):
""" do threaded stuff here """
...
Thread(target=MyClass().r
] On Behalf Of
Mick Krippendorf
Sent: Monday, October 12, 2009 10:52 PM
To: python-list@python.org
Subject: Re: deepcopy of class inherited from Thread
VYAS ASHISH M-NTB837 schrieb:
> I have an object which has a run() method. But I can call it only
once.
> Calling the start() again wil
VYAS ASHISH M-NTB837 schrieb:
> I have an object which has a run() method. But I can call it only once.
> Calling the start() again will give
>
> RuntimeError: thread already started
>
> So what is the way to do this?
>
> I thought of doing a deep copy of the object, as shallow copy will also
>
-list@python.org
Subject: Re: deepcopy of class inherited from Thread
VYAS ASHISH M-NTB837 wrote:
> Dear All
>
> I am running this piece of code:
>
> from threading import Thread
> import copy
>
> class Ashish(Thread):
> def __init__(self, i):
>
VYAS ASHISH M-NTB837 wrote:
Dear All
I am running this piece of code:
from threading import Thread
import copy
class Ashish(Thread):
def __init__(self, i):
Thread.__init__(self)
self.foo = i
def run(self):
print (self, self.foo)
d= Ashish(4)
e = copy.de