[omaha] Python SOAP and Apache

Jeff Hinrichs - DM&T jeffh at dundeemt.com
Mon May 19 21:20:06 CEST 2008


On Mon, May 19, 2008 at 10:36 AM, freeav8r <freeav8r at yahoo.com> wrote:
> Hi Jeff and all,
>
> Thanks for the response.  The WSGI mod appears to be
> what we're looking for to connect to Apache.  We need
> true connection pooling though since we won't know
> which of many databases to connect to until the
> individual request is processed.
>
> If we are to run the CherryPy application as WSGI in
> apache without requiring the internal CherryPy engine
> to be run (this appears to be the most efficent
> setup), any suggestions on implementing connection
> pooling with apache and mysql so that the python
> application has access to the connections?
The link I posted, http://tools.cherrypy.org/wiki/Databases gives a
good way to setup your connections on a per thread basis for mysql.
When you are using mod_wsgi, you can tell it (as opposed to the
cherrypy server) how many instances/threads to start and set a
maximum.  How many different DB connections are you talking about? In
the example, they use a simple vector, db, as the solution for
cherrypy.thread_data.  However, nothing precludes you from using a
list or dictionary of connections.
i.e.

def connect(thread_index):
    # Create a connection and store it in the current thread
    cherrypy.thread_data.db = {}
    cherrypy.thread_data.db['db1'] = MySQLdb.connect('host', 'user',
'password', 'dbname')
    cherrypy.thread_data.db['db2'] = MySQLdb.connect('host2', 'user2',
'password2', 'dbname2')
    ...

If you have 20 databases, each thread would have 20 connections -- 1
to each db.  Then it would depend on how many threads/processes you
end up starting. I've used similar for an app that connected for 4
different databases.

hope that helps.

-jeff

>
>
> -freeav8r
>
>
> --- Jeff Hinrichs - DM&T <jeffh at dundeemt.com> wrote:
>
>> While I haven't done any SOAP with python, here are
>> some of the things
>> that I know.
>>
>> CherryPy can run under apache via mod_wsgi
>>
> http://code.google.com/p/modwsgi/wiki/IntegrationWithCherryPy
>>  so you
>> should be able to get yourself all the goodness of
>> apache with pretty
>> much no code modification.
>>
>> Connection Pooling: depends on the database you are
>> using.  Is it
>> thread-safe?  See
>> http://tools.cherrypy.org/wiki/Databases for more
>> insight.
>>
>> regards,
>>
>> Jeff
>>
>> On Mon, May 19, 2008 at 9:53 AM, freeav8r
>> <freeav8r at yahoo.com> wrote:
>> > Hi All,
>> >
>> > I need to implement a number of SOAP web services
>> in
>> > Python for an enterprise level system (lots of
>> > traffic).  Prototypes are up and running on
>> cherrypy's
>> > WSGI server without any form of connection pooling
>> for
>> > the database connections.
>> >
>> > Any suggestions on what technologies and
>> frameworks
>> > that will allow the following:
>> >
>> > 1.  Ability to utilize existing apache web servers
>> > 2.  Connection pooling to a database for the
>> database
>> > connections that the web services will consume
>> > 3.  Generation of WSDL for (and compatibility
>> with)
>> > Python, Java, and Microsoft .net clients.
>> >
>> > Any suggestions?  Anyone on the list already doing
>> > this?
>> >
>> > -freeav8r
>> >
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > Omaha Python Users Group mailing list
>> > Omaha at python.org
>> > http://mail.python.org/mailman/listinfo/omaha
>> > http://www.OmahaPython.org
>> >
>>
>>
>>
>> --
>> Jeff Hinrichs
>> Dundee Media & Technology, Inc
>> jeffh at dundeemt.com
>> 402.218.1473
>> web: www.dundeemt.com
>> blog: inre.dundeemt.com
>> _______________________________________________
>> Omaha Python Users Group mailing list
>> Omaha at python.org
>> http://mail.python.org/mailman/listinfo/omaha
>> http://www.OmahaPython.org
>>
>
>
>
>
> _______________________________________________
> Omaha Python Users Group mailing list
> Omaha at python.org
> http://mail.python.org/mailman/listinfo/omaha
> http://www.OmahaPython.org
>



-- 
Jeff Hinrichs
Dundee Media & Technology, Inc
jeffh at dundeemt.com
402.218.1473
web: www.dundeemt.com
blog: inre.dundeemt.com


More information about the Omaha mailing list