[plt-scheme] Web Server Send/Suspend/Finish questions
To answer your question directly: set the timeout once,
when the servlet is loaded.
However, I recommend two things:
- update to 352.7. All the cool kids are using it.
We've been running it for, oh, half a day now with now
problems.
- Use the v2-transitional servlet interface which gives
you much greater control over continuation expiry. Example
code is below. The definition of manager is the main thing
to look at.
HTH,
Noel
(module sbcs mzscheme
(require
(lib "main.ss" "sbcs")
(lib "response.ss" "web-server")
(lib "servlet.ss" "web-server")
(lib "lru.ss" "web-server" "managers")
)
(provide interface-version
timeout
instance-expiration-handler
manager
start)
(define interface-version 'v2-transitional)
(define timeout +1800.0)
;; start : request -> response
(define (start initial-request)
(parameterize
([current-servlet-continuation-expiration-handler
handle-expired-continuation])
(go initial-request)))
(define (instance-expiration-handler request)
(handle-expired-instance request))
;; manager : LRU-manager
;;
;; An instance (or continuation?) is allowed to live a
;; maximum of 6 hours (30 minutes x 12), and a minimum of
;; 1 minute (5 seconds x 12). Lifetime is controlled by
;; memory usage. Usage above 256MB will result is more
;; rapid death. This caps the max size of uploaded files
;; to around 100MB, which should still be plenty.
(define manager
(create-LRU-manager
;; Called when an instance has expired.
instance-expiration-handler
;; The condition below is checked every 5 seconds
5
;; One 'life point' is deducted every 30 minutes
(* 30 60)
;; If this condition is true a 'life point' is
deducted
;; from the instance (or is it continuation?)
(lambda ()
(>= (current-memory-use)
(* 256 1024 1024)))
;; The number of 'life points' an instance (or
continuation?) starts with
#:initial-count 12
;; Logging done whenever an instance (or
continuation?)
;; is collected
#:inform-p (lambda (removed)
(printf "Collected instance: ~S memory
use: ~SM~n"
removed
(round (/ (current-memory-use)
(* 1024 1024)))))))
)
--- Hans Oesterholt-Dijkema <hdnews at gawab.com> wrote:
>
> How should I use
>
>
> __|adjust-timeout!|__
>
>
<http://download.plt-scheme.org/doc/352/html/web-server/web-server.html#node_toc_node_sec_Temp_12>
>
> To set the timeout value in a servlet. Do I need to
> repeat it before each suspend?
>
> --Hans
>
>
Email: noelwelsh <at> yahoo <dot> com noel <at> untyped <dot> com
AIM: noelhwelsh
Blogs: http://monospaced.blogspot.com/ http://www.untyped.com/untyping/
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com