Kevin Dangoor wrote:
> On 6/30/06, Charles Duffy <[EMAIL PROTECTED]> wrote:
>> Kevin Dangoor wrote:
>> > I thought I fixed this, and I "sort of" did. Once you hit the
>> > database, this shouldn't happen. I just added an explicit call in
>> > startup.startTurboGears that will hopefully take care of this.
>>
>> That doesn't actually appear to resolve the problem. I'm stumped as to
>> why, though -- since bind_meta_data() is always issuing a new connect()
>> to the engine, the DynamicMetaData should always have an engine bound if
>> bind_meta_data() has been called within that thread; however, even
>> adding a bind_meta_data() call at the top of the method where the
>> exception is thrown, the issue still occurs.
>
> Odd. That almost makes it sound like it's a different metadata
> instance, but I'm not sure how that would be possible. I don't seem to
> see this error if I touch the database soon after starting the server.
> (At least, I haven't seen this error since last night...)
Looks like it's the same metadata but different threads. I added some
debug statements and got the following results:
2006-06-30 07:54:18,196 turbogears.database DEBUG No action taken;
metadata 0x-48a944f4 already bound for thread 0x-49d4b450
2006-06-30 07:54:18,196 turbogears.identity.savisit DEBUG Metadata
0x-48a944f4 not bound for thread 0x8161a64
To get this, I added the following to the beginning of
update_queued_visits()
turbogears.database.bind_meta_data()
if not turbogears.database.metadata.is_bound():
log.debug('Metadata 0x%x not bound for thread 0x%x' %
(id(turbogears.database.metadata), id(thread.get_ident())))
assert turbogears.database.metadata.is_bound()
and modified turbogears.database.get_engine() as so:
def get_engine():
"Retreives the engine based on the current configuration"
global _engine
if not _engine:
log.debug('Creating initial connection to engine')
dburi = config.get("sqlalchemy.dburi")
if not dburi:
raise KeyError("No sqlalchemy database config found!")
_engine = sqlalchemy.create_engine(dburi)
metadata.connect(_engine)
elif isinstance(metadata, BoundMetaData) and not
metadata.is_bound():
log.debug('Reconnecting unbound metadata to engine')
metadata.connect(_engine)
else:
log.debug('No action taken; metadata 0x%x already bound for
thread 0x%x' % (id(metadata), thread.get_ident()))
return _engine
Now, why the heck the get_engine() call is being executed in a different
thread from the visit code which is calling it is rather beyond me...
but hopefully it'll provide something of a clue.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-trunk
-~----------~----~----~----~------~----~------~--~---