<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">[..] </div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">&gt;&gt; There&#39;s a branch of Twisted that implements this, hopefully it will<br>
&gt;&gt; eventually be merged:<br>
&gt;&gt; <a href="http://twistedmatrix.com/trac/ticket/3711" target="_blank">http://twistedmatrix.com/trac/ticket/3711</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt; Is there anything that is currently holding this up?  (ie. is the design<br>
&gt; on<br>
&gt; this branch what will end up in the system or could it change<br>
&gt; dramatically?)<br>
<br>
</div>There are a bunch of review comments in the ticket. You could just write<br>
your own until this is ready, I&#39;ve done it a number of times and it&#39;s a<br>
pretty small piece of code.<br></blockquote><div><br></div><div>I started writing one of my own today (basically a wrapper in render_GET that calls an deferrable render_GET).</div><div><br></div><div>Something like this:</div>
<div><br></div><div>  def _bg_GET(self, request):</div><div>      # Do something slow</div><div>      request.write(result)</div><div>      return request</div><div><br></div><div>   def render_GET(self, request):</div><div>
      d = deferToThread(self._bg_GET, request)</div><div>      d.addCallback(lambda r: r.finish())</div><div>      return NOT_DONE_YET </div><div><br></div><div>That seems to work, but I would like to </div><div>   a) not use the deferToThread() and </div>
<div>   b) do something that doesn&#39;t sacrifice too much performance. </div><div><br></div><div>At the end of the day, what I would really like is something in render_GET that checks the return from calling the internal GET method and if it is a deferred it adds a callback to finish the request, if not it simply returns the result.  (this would allow me to use deferToThread, inlineCallbacks, etc as needed in my get methods)</div>
<div><br></div><div>Can you see any issues with doing something like this?  (it seems almost too simple so I expect that I must be missing something)</div><div><br></div><div>-Allen</div><div><br></div></div>