can you attach a quick single-file .py script that I can run, and will show how you're getting this error? you might be in an "impossible" block there, in that you are trying to add an event listener within that same event, but I need to see if what you're doing is really something that should be made to work. That is, perhaps declarative should use a different system internally for the __declare_first__ in order to get around this.


On 08/15/2016 09:38 AM, Tom Kedem wrote:
I'm trying to create a dynamic many_to_many relationship, inspired by:
http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/
https://bitbucket.org/zzzeek/pycon2014_atmcraft/src/f50cbe745a19/atmcraft/model/meta/?at=master
(orm.py and schema.py)

I've got it working with just creating a secondary table in the
__declare_first__ hook.

Now I want it to be a "secondary" class and not just a table - and I'm
having trouble.
I've created a declared class in the __declare_first__ hook. Creating
that class causes (Full stacktrace at the bottom):
RuntimeError: deque mutated during iteration

I suppose new events are being added when I do so. Searching google I
came upon these:
https://bitbucket.org/zzzeek/sqlalchemy/issues/3163/use-deque-for-event-lists-so-that-remove
https://bitbucket.org/zzzeek/sqlalchemy/commits/4a4cccfee5a2#Llib/sqlalchemy/event/api.pyT61

But since I'm not creating those events explicitly (I suspect the
declared class creates them), I'm not sure about how to proceed.

Full stacktrace if it's helpful:
  File
"C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\orm\instrumentation.py",
line 347, in _new_state_if_none
    state = self._state_constructor(instance, self)
  File
"C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\util\langhelpers.py",
line 754, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
  File
"C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\orm\instrumentation.py",
line 177, in _state_constructor
    self.dispatch.first_init(self, self.class_)
  File
"C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\event\attr.py", line
256, in __call__
    fn(*args, **kw)
  File
"C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\orm\mapper.py", line
2943, in _event_on_first_init
    configure_mappers()
  File
"C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\orm\mapper.py", line
2822, in configure_mappers
    Mapper.dispatch._for_class(Mapper).before_configured()
  File
"C:\Users\vToMy\PycharmProjects\sqlalchemy\lib\sqlalchemy\event\attr.py", line
217, in __call__
    for fn in self.parent_listeners:
RuntimeError: deque mutated during iteration


--
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 https://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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to