Christopher Stawarz ha scritto:
On May 7, 2008, at 4:44 AM, Manlio Perillo wrote:
[...]
I don't think this will solve the problem.
Moreover in your example you buffer the whole request body so that you have to yield only one time.

Your example was:

def application(environ, start_response):
  def nested():
     while True:
        poll(xxx)
        yield ''
     yield result

  for r in nested():
     if not r:
         yield ''

  yield r

My suggestion would allow you to rewrite this like so:

@awsgiref.callstack.add_callstack
def application(environ, start_response):
  def nested():
     while True:
        poll(xxx)
        yield ''
     yield result

  yield nested()

The nesting can be arbitrarily deep, so nested() could yield doubly_nested() and so on. While not as elegant as greenlets, I think this does address your concern.



I'm reading the PEP 342, and I still think that this will not work as I want for Nginx (where I have no control over the "scheduler").

In fact the PEP 342 says:
"""However, if it were possible to pass values or exceptions *into* a
generator at the point where it was suspended, a simple co-routine
scheduler or "trampoline function" would let coroutines "call" each
other without blocking."""



However writing a co-routine scheduler or "trampoline function" when your application is embedded in an external server is not possible (but please, correct me if I'm wrong).




> [...]


Regards   Manlio Perillo
_______________________________________________
Web-SIG mailing list
Web-SIG@python.org
Web SIG: http://www.python.org/sigs/web-sig
Unsubscribe: 
http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com

Reply via email to