I'm not entirely sure about what you're trying to do, but you can dissect
bootstrap pretty easily.
`get_app` takes a while because it parses the ini file and loads your app.
Just like pserve, you only have to do this once for the process.
After that, call `prepare` once per thread, or as many times as you want.
If you're calling it a lot you'll want to invoke the closer to cleanup each
time or all of those requests will hang around.
Anyway what I've said looks somewhat similar to your gist.
The registry argument to `prepare` is important if your INI file has
multiple pyramid apps. For example, you're using a [composite:main] to
dispatch between different apps, and you invoke `get_app('my.ini')` without
specifying which pyramid app to load. It'll load all of them. At which
point which one does `prepare` actually use?? It uses the last pyramid app
loaded unless you specify which registry you want to use. This works most
of the time because few people seems to use the composite applications in
the same process. A workaround is to invoke `get_app('my.ini#myapp')` to
only load the specific app you want (which could also reduce your startup
time).
HTH,
Michael
On Fri, Jun 14, 2013 at 11:45 AM, Jonathan Vanasco <[email protected]>wrote:
> I need an opinion on the 'safety' of a potential approach...
>
> Calls to `pyramid.paster.bootstrap` are definitely what is taking too long
> ( 2.5s on dev ! )
>
> Looking at the path of execution and relevant bits...
>
> `pyramid.paster` `bootstrap`
>
> calls `paste.deploy` `get_app` ( which looks to be expensive )
> calls `pyramid.scripting` `prepare` ( which may or may not be
> expensive )
>
> `pyramid.scripting` `prepare`
> does a lot of stuff with threadlocals / etc. and that scares me.
>
> my idea is to pull the app out of the env, then create a new env -
> injecting that app into it.
>
> the gist is below...
>
> https://gist.github.com/jvanasco/5783417
>
> i'm wondering if this is safe, or if much of it is needed :
>
> - do i need to update the 'app' ? is that used on anything ?
> - should i pull the `registry` out of the env and pass that into
> `prepare_request` too ?
>
> any ideas ?
>
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/pylons-discuss.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.