On Thursday 06 December 2001 10:35, Daniel Popowich wrote:
> What happens then on a heavily loaded system when 100s or more are
> hitting the same Servlet?  Could this not lead to disaster if in my
> code I always refer to self.request() to get the request object?
> Couldn't one request overwrite another?

canBeReused() is only part of the story.  There's another method 
called canBeThreaded() that returns False by default.  Unless this is 
set to True, each thread will use a separate instance of the servlet. 
If you have 10 threads you will have a pool of 10 servlet instances.  
Thus, there is no problem with concurrency.

> My assumptions about caching data:
>
>    1. Use sessions for data meaningful to a user across multiple
> Servlet requests
>    2. Use fields (of the request object) for data meaningful for a
>       single request (e.g., in awake(), stuff the request object
> with info needed in respond().

Those are both correct.

>    3. Use instance attributes for data meaningful across all
> sessions and requests.

No, use something else for this.  You should use a database, a ZODB 
store, or something else with the appropriate synchronization 
mechanisms to avoid conflicts between threads.  Store a reference to 
your shared object in a python module that can be imported from 
anywhere, or as an attibute of the Application.




_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to