This is my Python Code :
import threading
import time
import MySQLdb
import sys
conn=MySQLdb.connect (host = "localhost",
user = "root",
passwd = "",
db = "profiles_sheduleit")
cur = conn.cursor()
def activation():
while True:
time.sleep(1)
print time.time()
t = threading.Thread(name='activation', target=activation)
t.start()
I am calling this page from my php page by:
$result = exec("c:/python27/python f:/python/hello.py");
I have one few buttons in php when this button is clicked a new thread should me created and that thread should run for 10 seconds.
but when i click the button m not able to click another button because python script goes into sleep mode thanx
-
6activation function, has an infinite loopGntem– Gntem2012年07月11日 10:31:54 +00:00Commented Jul 11, 2012 at 10:31
1 Answer 1
your python script never terminates because your thread runs for ever due to your while True: statement. This causes the exec function to wait indefinitely. All PHP's exec like functions are blocking, meaning that they'll wait until the process they call has returned.
Look into something like gearman, if you want to create a work queue. It's essentially a job server that allows for async execution.