It sounds like you are describing the Scheduler (in the book).  This is a 
completely separate instance of Python and web2py that can run long-running 
things in a different process from the website.  I use it for reading large 
files and populating the database, or generating long reports.  In both 
cases I don't want to impact the responsiveness of my website by executing 
a long-running function.

The Scheduler has full access to all of the power of web2py tables, 
functions, etc.  It is started as a separate process with one or more 
"workers" (each a separate process) and the communication is handled 
through a shared database.  it is both monstrously powerful and simple to 
use.  it is one if the five best features in web2py, IHMO.

-- Joe B.

On Sunday, January 26, 2014 10:39:09 AM UTC-8, desta wrote:
>
> This in an interesting approach.
>
> What would be a proper way to implement this?
> I imagine that a controller in web2py populates a queue. And you need 
> another python script to check this queue, which is stored in a table in 
> the db, and execute them. Would this python script be an external to 
> web2py? If so, would it be possible to access the tables of the db inside 
> web2py?
>
> Thanks.
>
> On Tuesday, July 9, 2013 9:10:20 AM UTC+3, Encompass solutions wrote:
>>
>> Other solutions include a queuing server.  Another python process 
>> whatching for new things to do and executes that way.  Much cleaner than 
>> running another subprocess.  But takes longer to do.
>>
>>
>>
>> On Tue, Jul 9, 2013 at 2:19 AM, Vinicius Assef <vinic...@gmail.com>wrote:
>>
>>> It depends how you want your external script be executed.
>>>
>>> But you can use subprocess.Popen() or subprocess.call().
>>>
>>> On Mon, Jul 8, 2013 at 4:47 PM, pratt <pratyus...@gmail.com> 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+un...@googlegroups.com.
>>> > For more options, visit https://groups.google.com/groups/opt_out.
>>> >
>>> >
>>>
>>> --
>>>
>>> ---
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.

Reply via email to