1) Do not do .sys.path.append(...) in a controller. it is not thread safe and you will end up with a memory leak. 2) You should use processing.Popen('external script') you can cache in ram the resulting object.
On Monday, 8 July 2013 14:20:56 UTC-5, pratt wrote: > > * > * > *I would like to run the external python script testQEF when the button > on the html page is clicked.The below code is my html page* > > index.html > > ------------------------------------------------------------------------------------- > {{extend 'layout.html'}} > > <p>Please Enter the old Modcod</p> > > <form> > <INPUT type="text" id="q" name = "q" value=""/> > <INPUT type="button" value="Run Test" > onclick="ajax('{{=URL('data')}}',['q'],'target');"/> > </form> > <br/> > <div id="target"></div> > > > ------------------------------------------------------------------------------------------ > The below code is my controller default.py > > # coding: utf8 > # try something like > import threading > import time > import sys > sys.path.append('C:/Users/pratt/Workspace_Eclipse/Copy of > MasterSolution_COPY') > *# I am importing the external python script using sys,path* > import testQEF > a = 0 > heyo = 'zero' > > def index(): > > return dict(toobar=response.toolbar()) > > def data(): > > if not session.m or len(session.m)==20: session.m=[] > if request.vars.q: session.m.append(request.vars.q) > session.m.sort() > *# starting the thread to run my external python script* > h.start() > return TABLE(*[TR(v) for v in session.m]).xml() > #return dict(toobar=response.toolbar()) > #hey = wut() > > *# I have created a class to create the thread* > class testrun(threading.Thread): > def __init__(self): > threading.Thread.__init__(self) > > def run(self): > > #heyo = 'heyo' > #self.newtest = 'hey new test' > #if a == 0: > # response.flash=T("you have run the thread a successfully") > #time.sleep(10) > #response.flash=T("you have run the thread a unsuccessfully") > > testQEF.testFunc(999, > 9, > 0.9, > 100000000, > 30.0, > 0.0, > 0.1, > "10.169.6.74", > 3, > 3, > 1, > 2, > str("C:/testdir/webservertest")) > > *#Initiating the Thread * > h = testrun() > > def returnA(): return 'A' > > class wut(): > def __init__(self): > self.foo = 'B' > > > > > *I cannot run my external python script when I click the button and also > When I do this the server is freezing.I am new to Web2py,Could Anyone help > me in this Regard.I need solution as soon as possible.* > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.