Hey folks. Since there is some confusion on my library, let me put out
some code.
Lets say I have a libWebData.so, and i have python bindings to it. The
way I init and use it is:
webDataInit(myCallback)
webDataGetEmployeeDetails(ID=100) # This call goes into libWebData.so
which spawns a pthread and immediately returns
Then after some time, you get a callback.. the library calls something
like:
myCallback(dataID=100, {'name':'TG', 'age':'2'})
Now the problem is if i make this sequence synchronous in my library,
i'll DoS myself in TG. The cherrypy pool only has 10 threads. So, each
thread is waiting on this data which can take however long.. So, if 10
people connect at once and are waiting for the synchronous call to
finish, no one else can access the webserver even though they are doing
nothing related to the data. As you can see, increasing the thread pool
will also be useless, because it wont server the actual purpose of
resource throttling then, and you WILL get DoS'ed under a load of users
== thread_pool_size.
So, one solution can be to order cherrypy to remove the current thread
from the thread pool until the callback is called, and in which case
the callback does something in it to put itself back into the thread
pool or something. I have no clue if there is a way for this.. If there
is, how do i implement a timeout in the case where the callback didn't
come back forever?
Igor, your solution 1, and 2 involve the threads waiting, and this
means if i have 10 threads waiting, i'll DoS myself due to the above
described thread_pool problem.
Diez, How does your callback class work? Lets say TG's index()
controller gets the request.
def index(kw, arg):
eID = int(kw['employeeID'])
webDataGetInit(diezCallback)
webDataGetEmployeeDetails(ID=100)
return <what?> # some code to tell browser to keep waiting? or may be
some JS code to poll the server
after 10 seconds lib calls back with:
diezCallback('100'. {'name':'TG'})
Now, i store this is stored into the session as you said. What happens
now? how do i access that session from JS? Does that session stay
active for ever until the web browser does the request for it? Or, is
the session reply stored into a DB/file and the callback returns.. ?
Then later on when JS checks, we do a DB query and return the result?
What if the session never got invoked or took a very long time that the
JS poll timed out.. (lets say we limit number of times we poll so
server isn't DoS'ed?)
thanks for the help
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---