On Mon, May 12, 2014 at 4:53 PM, Michael Bayer <[email protected]>wrote:

>
> On May 12, 2014, at 2:30 PM, Sylvester Steele <[email protected]>
> wrote:
>
>
>> the code here isn’t really showing me the nature of the two separate
>> connections.   They will be different unless you’re using “threadlocal” on
>> the engine or pool and both are in the same thread.  A simple comparison of
>> the “raw” DBAPI connections to see if they are different objects will
>> suffice (make sure you’re on the ultimate DBAPI connection though, not the
>> “fairy” object).   However note that Microsoft ODBC drivers also feature
>> connection pooling, so you’d need to turn it off at the ODBC configuration
>> level as well.
>>
>
> Hopefully the following details will help. Here is the sanitized code and
> logs:
>
>
>
> well the create_engine() statement isn’t here which is really what would
> illustrate if you’re doing some kind of thread local thing up there.  It
> looks a lot like your ODBC driver is pooling connections, as we see lots of
> pyodbc.connection objects with different identifiers, but yet it says the
> connection is busy with other results, additionally we see that you have a
> cursor local to select() yet some kind of error is being raised lots which
> illustrates continuous “connection closed” issues.
>
> so same answer, look to see that you don’t have anything thread local on
> your engine and look that you don’t have pooling in your ODBC driver turned
> on.
>
>
I will look again. The engine creation logic is quite separate from the
query execution logic. The code that creates engines is threadsafe to make
sure that only one engine is created per session per DB. So, all these
threads would be using the exact same engine (because the query that they
are all executing goes to the same DB). The first thread which reaches the
select function will be the only thread to actually create an engine. This
engine is then cached and reused by all other threads.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to