You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlalchemy
Hi,
I'm troubleshooting some code that uses thread_pool_executor to run a function, passing an ORM entity as an argument. Within the executed function, we are sometimes receiving a "Value Error: generator already executing" when accessing a related entity via a relationship property.
I'm guessing we shouldn't be passing ORM objects to threads, but rather just passing IDs and then querying the full object in the thread function. Does that hunch sound correct?
Jonathan Vanasco
unread,
Jul 5, 2022, 12:51:52 PM7/5/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlalchemy
> I'm guessing we shouldn't be passing ORM objects to threads, but rather just passing IDs and then querying the full object in the thread function
If you are simply dealing with read-only concepts, you can `.expunge` an object from one session/thread and `.merge` it into another session/thread. This is often playing with fire though, as you must be prepared to handle situations where the data may have changed as that type of work is not transaction-safe. See: https://docs.sqlalchemy.org/en/14/orm/session_state_management.html
Ben Chopson
unread,
Jul 5, 2022, 1:20:34 PM7/5/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlalchemy
Thanks Jonathan, that should help me move forward.