[DB-SIG] Number of connections problem with ctsybase module

Eric Brunel brunel@nortelnetworks.com
Wed, 11 Oct 2000 16:15:34 +0200


This is a multi-part message in MIME format.
--------------30E69998478ECFA6871FA393
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi again,

I finally figured it out by myself: this wasn't a problem of limit in the Sybase license,
but a limitation to the client library itself. To increase the number of connections, just
apply the attached patch to the ctsybasemodule.c source file in the ctsybase module
distribution, and it should work. It just changes a parameter in the Sybase context to
allow more connections than the default 25.

Anyway, thanks for the answer.
 - Eric -


> Eric Brunel wrote:
> >
> > Hi everybody,
> >
> > I'm using Python with the ctsybase module to design a server for a database
> > application. I need to open many database connections for the server, but apparently,
> > the ctsybase module limits the number of connections to 25. More simply, if I do the
> > following simple program:
> >
> > import ctsybase
> > l = []
> > for i in range(30):
> >   l.append(ctsybase.ctsybase({'server':'my_server', 'user':'my_user',
> > 'password':'my_password'}))
> >   print len(l),
> >
> > the result is:
> >
> > 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
> > Traceback (innermost last):
> >   File "<stdin>", line 2, in ?
> > SybaseError: ['failed to connect to server', ('client', 1, 16843014, 'ct_connect():
> > user api layer: external error: The maximum number of connections have already been
> > opened.', 0, '', 0, '08000')]

--------------30E69998478ECFA6871FA393
Content-Type: text/plain; charset=us-ascii;
 name="no_limits.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="no_limits.patch"

26a27,30
> /* === EB - 10/10/2000: define to enable EB's enhancements */
> #define EB_ENHANCED 1
> /* === */
> 
2074a2079,2083
>     /* === EB - 10/10/2000: maximum number of connections and return code */
> #ifdef EB_ENHANCED
>     int maxConnect = 200; /* or whatever value you want */
> #endif
>     /* === */
2096a2106
> 	
2098d2107
<     
2102a2112,2124
> 
>     /* === EB - 10/10/2000: trying to increase maximum number of connections */
> #ifdef EB_ENHANCED
>     retstat = ct_config(PySybContext, CS_SET, CS_MAX_CONNECT, &maxConnect, CS_UNUSED, NULL);
>     if (retstat != CS_SUCCEED)
>     {
> 	char msg[128];
>         sprintf(msg, "failed to set maximum number of connections [%d]", (int)retstat);
>         Py_FatalError(msg);
>     }
> #endif
>     /* === */
> 

--------------30E69998478ECFA6871FA393--