On Tue, Feb 16, 2010 at 12:08 PM, Veloz <[email protected]> wrote:
> Let's try it this way: the httpserver code you refer to is not really
> executed by paster directly, is it? The httpserver code is python code
> (I can see the source file on my computer, it's apparently not bundled
> into paster.exe) that has to be parsed and executed by some instance
> of python., and I suspect paster does not have a built in python
> interpreter that it's using.

There's no sub-interpreter. Python starts first and executes the
top-level 'paster' script.  (On Unix the "#!/usr/bin/env python" line
triggers this behavior in the OS; on Windows I'm not sure if a .bat
script is used.)  The Pylons Execution Analysis [1] shows what's
happening.  PasteDeploy instantiates the server and application as
specified in the INI file, and calls ``server(app)``.

The server (PasteHTTPServer) sets up a thread pool and listens for
requests. When a request comes in, it takes a free thread, runs the
request in it (i.e., sets up a WSGI environment and calls the
application), and returns the thread to the pool.

The ctrl-C issue is just how Python handles threads. I sometimes have
to press ctrl-C twice or get a delayed shutdown like you're talking
about. "paster serve --reload" adds another layer of complexity with
its subprocess. A more complete answer would require studying Python's
thread behavior and how Paste uses threads. I haven't studied this, or
kept track of how Paste shuts down compared to other frameworks. I do
know that Paste successfully kills off child threads, whereas when I
was using another framework (Quixote), I had to manually kill child
processes.  I've also seen a case where a chart library with a C
extension wrote its file several minutes after the request supposedly
ended and the chart object went out of scope.

[1]  http://bitbucket.org/sluggo/pylons-execution/src/tip/execution.rst
(Temporary location of 0.10/1.0 version until it can be incorporated
into the Pylons docs.)

-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to