On Tuesday, May 1, 2018 at 1:17:31 AM UTC-4, jens.t...@gmail.com wrote:
> I’ve followed the suggested cookie cutter code exactly: > https://github.com/Pylons/pyramid-cookiecutter-alchemy, which uses > pyramid_tm and adds the SQLA session to that transaction manager. > Are you passing in `*use_tweens=True*` ? https://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#pyramid.request.Request.invoke_subrequest https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/subrequest.html?highlight=use_tweens#subrequests-with-tweens If not, the behavior you show is expected. `pyramid_tm` handles the transaction begin/commit via tweens. If the subrequests don't use the tweens, they're part of your main transaction and don't close the dbconnection or return it to the pool. So they will require 1 db connection for main + [1 db connections for each subrequest]. If you are not enabling tweens in the subrequest, then Pyramid doesn't work how I'd imagine it to. But this behavior makes sense for pyramid_tm without tweens enabled. Sidenote: I don't know if transaction/pyramid_tm can handle subrequests like this. You might want the functionality that Michael Merickel suggested above, by copying over the main db session. Like most others though, I avoid subrequests at all costs. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/5d4743af-52c2-489d-8344-1f688a085cb2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.