[Checkins] SVN: z3c.saconfig/trunk/src/z3c/saconfig/zcml.py Added a patch by Malthe; it's useful for MySQL to be able to control

Vincent Fretin vincent.fretin at gmail.com
Fri Jun 26 09:45:01 EDT 2009


Yeah by default MySQL will ``disconnect automatically`` if no activity
is detected on a connection for eight hours.

I don't use z3c.saconfig but z3c.sqlalchemy, and I had to create the
wrapper like this:

wrapper = createSAWrapper(connection_string, model=model,
name='enterprisedata', engine_options={'pool_recycle':7200})

Vincent Fretin



On Fri, Jun 26, 2009 at 2:06 PM, Martijn Faassen<faassen at startifact.com> wrote:
> Log message for revision 101287:
>  Added a patch by Malthe; it's useful for MySQL to be able to control
>  pool_recycle, otherwise the connection dies on the long term.
>
>
> Changed:
>  U   z3c.saconfig/trunk/src/z3c/saconfig/zcml.py
>
> -=-
> Modified: z3c.saconfig/trunk/src/z3c/saconfig/zcml.py
> ===================================================================
> --- z3c.saconfig/trunk/src/z3c/saconfig/zcml.py 2009-06-26 09:45:31 UTC (rev 101286)
> +++ z3c.saconfig/trunk/src/z3c/saconfig/zcml.py 2009-06-26 12:06:41 UTC (rev 101287)
> @@ -27,13 +27,31 @@
>         required=False,
>         default=False)
>
> +    pool_size = zope.schema.Integer(
> +        title=u"Pool size",
> +        description=u"Number of connections to keep open inside the connection pool.",
> +        required=False,
> +        default=5)
> +
> +    pool_recycle = zope.schema.Integer(
> +        title=u"Pool recycle",
> +        description=u"Recycle connections after the given number of seconds have passed.",
> +        required=False,
> +        default=-1)
> +
> +    pool_timeout = zope.schema.Integer(
> +        title=u"Pool timeout",
> +        description=u"Number of seconds to wait before giving up on getting a connection from the pool.",
> +        required=False,
> +        default=30)
> +
>     setup = zope.schema.BytesLine(
>         title=u'After engine creation hook',
>         description=u'Callback for creating mappers etc. One argument is passed, the engine',
>         required=False,
>         default=None)
> +
>
> -
>  class ISessionDirective(zope.interface.Interface):
>     """Registers a database scoped session"""
>
> @@ -62,8 +80,11 @@
>         default="z3c.saconfig.utility.GloballyScopedSession")
>
>
> -def engine(_context, url, name=u"", echo=False, setup=None, twophase=False):
> -    factory = utility.EngineFactory(url, echo=echo)
> +def engine(_context, url, name=u"", echo=False, setup=None, twophase=False,
> +           pool_size=5, pool_recycle=-1, pool_timeout=30):
> +    factory = utility.EngineFactory(
> +        url, echo=echo, pool_size=pool_size,
> +        pool_recycle=pool_recycle, pool_timeout=pool_timeout)
>
>     zope.component.zcml.utility(
>         _context,
>
> _______________________________________________
> Checkins mailing list
> Checkins at zope.org
> http://mail.zope.org/mailman/listinfo/checkins
>


More information about the Checkins mailing list