why should Session.expire_on_commit
be set to False
when using asyncio?
#11495
-
I'd love to understand better, why I also think I might have come across it somewhere else in the docs (not sure I can still find it) where it was recommended (probably for sync sessions) that TIA for your time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, It's just a suggestion to avoid having to manually refresh an object after a commit. Using async you cannot lazy load expired attributes after a commit like you would in case of sync code. |
Beta Was this translation helpful? Give feedback.
Hi,
It's just a suggestion to avoid having to manually refresh an object after a commit. Using async you cannot lazy load expired attributes after a commit like you would in case of sync code.
Note that there is a way of having lazy load work with asyncio, see
AsyncAttrs
https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html#sqlalchemy.ext.asyncio.AsyncAttrs