In article <50d06eb9-2b87-43a0-a7e2-6b68e35fc...@y34g2000prb.googlegroups.com>,
grocery_stocker wrote:
>
>Given the following code...
>
>import thread
Here's your problem; subclass threading.Thread instead, much easier.
--
Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft
Try the following, to call your function yourself in this way:
def myfunction(string,sleeptime,*args):
while 1:
print "string is ", string
time.sleep(sleeptime) #sleep for a specified amount of time.
f = myfunction
r = ("Thread No:1",2)
f(*r)
The key here is the *r synt
thread.start_new_thread(myfunc, "some string", 42)
This should have been
thread.start_new_thread(myfunc, ("some string", 42))
because all the subsequent values after the function-handle/name
get passed into the function when it gets called. As if the
start_new_thread() function was def
Maybe I'm missing it, but in the original code, the line had
thread.start_new_thread(myfunction,("Thread No:1",2))
It has a single arg ("Thread No:1",2) versus something like
thread.start_new_thread(myfunction,1, 2, ("Thread No:1",2))
But
def myfunction(string,sleeptime,*args):
clearly take
On Mar 25, 8:28 am, Tim Chase wrote:
> grocery_stocker wrote:
> > On Mar 25, 7:05 am, grocery_stocker wrote:
> >> Given the following code...
>
> >> #!/usr/bin/env python
>
> >> import time
> >> import thread
>
> >> def myfunction(string,sleeptime,*args):
> >> while 1:
>
> >> print st
grocery_stocker wrote:
On Mar 25, 7:05 am, grocery_stocker wrote:
Given the following code...
#!/usr/bin/env python
import time
import thread
def myfunction(string,sleeptime,*args):
while 1:
print string
time.sleep(sleeptime) #sleep for a specified amount of time.
if __
On Mar 26, 1:17 am, grocery_stocker wrote:
> On Mar 25, 7:05 am, grocery_stocker wrote:
>
>
>
> > Given the following code...
>
> > #!/usr/bin/env python
>
> > import time
> > import thread
>
> > def myfunction(string,sleeptime,*args):
> > while 1:
>
> > print string
> > time.
On Mar 25, 7:05 am, grocery_stocker wrote:
> Given the following code...
>
> #!/usr/bin/env python
>
> import time
> import thread
>
> def myfunction(string,sleeptime,*args):
> while 1:
>
> print string
> time.sleep(sleeptime) #sleep for a specified amount of time.
>
> if __nam
Given the following code...
#!/usr/bin/env python
import time
import thread
def myfunction(string,sleeptime,*args):
while 1:
print string
time.sleep(sleeptime) #sleep for a specified amount of time.
if __name__=="__main__":
thread.start_new_thread(myfunction,("Thread N