[hunchentoot-devel] Handling Lisp errors.
Otto Diesenbacher
diesenbacher at gmail.com
Mon Apr 16 20:12:31 UTC 2007
"Victor Kryukov" <victor.kryukov at gmail.com> writes:
> The second question is: how do you use CLSQL thread-safely with
> Hunchentoot / SBCL? SBCL don't provide thread properties, so my first
> solution[1] was to create a hash-table and to assign each thread a
> connection, to check from every thread whether it already has a
> connection, and then to clean that hash-table periodically, closing
> connections for dead threads. That worked pretty well, but I was
> afraid of exhausting limit of database threads somehow, so I switched
> to the second solution.
i put any database-communication out of an function, called via the
*dispatch-table*, into a (with-db (bla bla)) macro:
(defmacro with-db (&body body)
`(let ((clsql:*default-database*
(clsql:connect (list "127.0.0.1" "bla" "bla" "bla")
:pool t :database-type :postgresql)))
(unwind-protect
(progn
, at body)
(clsql:disconnect :database clsql:*default-database*))))
so any thread should get his own *default-database* from the clsql
connection pool?
--
okflo
More information about the Tbnl-devel
mailing list