On 10/25/15 3:37 AM, peon ma wrote:
> Hello
> 
> I have a problem with table reflection under multi-thread without lock.
> It works fine under single-thread or multi thread with lock protection.
> 
> I got following result by the attached test script:
> single-thread or multi thread with lock protection:  
>     It prints some logs of create connection, query metadata etc, and
> then the table reflection returned.
> multi-thread without lock protection:
>     table reflection returned before create connection and query
> metadata, without any exceptions, loggings, but got empty columns list
>     and after about 20ms(metadata of this table fetched), all threads
> works fine(got correct columns list)
> 
> 
> I did found any related documentation about this, so I want to know:
> Is it a bug?

no


> Or the reflection isn't thread-safe, 

it's not for a single MetaData object because the reflection process is
modifying the MetaData object and the Table objects within it

if so, is it thread-safe for
> reflection different tables?

only if those tables have no foreign key dependencies between them.  If
you reflect a table A which has a ForeignKeyConstraint to a table B, the
reflection of table B will occur automatically.



(see following code for example)
> |
> withtbl1_lock:
>   Table("table1",...)
> 
> withtbl2_lock:
>   Table("table2",...)
> |
> 
> 
> Thanks in advance
> 
> 
> -- 
> 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 sqlalchemy+unsubscr...@googlegroups.com
> <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
> To post to this group, send email to sqlalchemy@googlegroups.com
> <mailto:sqlalchemy@googlegroups.com>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to