Just wanted to follow up with the list on what I did for my task queuing using webware 
(seems to be working OK so far..)

Most of this will be "Duh!" to the experienced Webware folks here but I wanted to post 
this so others can get some ideas.

I used SQLObject (sqlobject.org) to manage a database table of tasks. 
Users request that tasks be created from a servlet page and new task-requests are 
added to the tasks table.
Once submitted the servlet redirects to a page which shows the task queue, it 
refreshes about every 10 seconds until it finds no tasks that are not completed, then 
it stops refreshing.
I created a single worker thread that periodically (every 5 seconds) looks for 
unprocessed tasks from the task table.
If it finds one, it processes it and puts the result back into the task table, marked 
as "completed"
The worker thread will keep doing this, one task at a time forever or until someone 
sends it a "die" message (which I do with a simple property).

But I have to set my thread running from somewhere so in the __init__.py of the 
context directory I :

#Context init.py file

from MyCode.threadworker import workerthread

w_thread = workerthread()

def contextInitialize(app, dir):
        startTasks()
        app.addShutDownHandler(stopTasks)

def startTasks():
    w_thread.start()
    print "Started worker thread"

def stopTasks():
    print 'Stopping working thread...'
    #It may take a few seconds for the thread to check its "die" property
    w_thread.die = 1
    
N¬HS^µéX¬²š'²ŠÞu¼Ž­§%{] ë\z»b~'¢{az-µë-¶§ëÞÚ!ŠÛazf«‘ëN­§%{] 
M©js«iÉ^×H•«,žŒÜ–X"½ìØ^{¦†ÛiÿöÊ&ý§b

Reply via email to