Thank you for the explanation, Jonathan! No, I didn't use *use_tweens* and 
perhaps will give that a try.

However, considering our other conversation 
<https://groups.google.com/forum/#!topic/pylons-discuss/2__fpRY09QE> 
regarding the requests package and how to issue API calls within a view 
callable, I’ll switch to using that anyway.

Jens



On Wednesday, May 2, 2018 at 3:38:10 AM UTC+10, Jonathan Vanasco wrote:
>
> 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/7ab21cf5-f387-4b2d-b644-0dc263c2397a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to