[Twisted-Python] AMP message length limit

Oon-Ee Ng ngoonee.talk at gmail.com
Sat Nov 28 13:03:09 MST 2015


On Sat, Nov 28, 2015 at 10:41 PM, Glyph Lefkowitz
<glyph at twistedmatrix.com> wrote:
>
> On Nov 25, 2015, at 04:54, Oon-Ee Ng <ngoonee.talk at gmail.com> wrote:
>
> On Tue, Nov 24, 2015 at 11:03 AM, Oon-Ee Ng <ngoonee.talk at gmail.com> wrote:
>
> And furthermore that when I do that, callRemote no longer returns a
> deferred (which makes sense, really) and instead gets a None. One more
> check before I add my default errBacks then. Optimised network traffic
> sounds positive, at the least (I assume this means one less
> transmission since it effectively makes the AMP one-way for the
> messages which have this set to False).
>
>
> Just realized, requiresAnswer=False means I can't add errBacks, which
> means there's no way to handle a receiver-side error. Is this correct?
>
>
> That is correct.  But you shouldn't want to handle errors there :-).  Don't
> think of a requiresAnswer=False command as an optimization; instead, think
> of it as a piece of information being relayed.
>
> For example; consider an HTTP stream.  The client sends a request.  If the
> server has an error, it sends an error code.  Then, the server sends the
> entity-body, one chunk at a time.
>
> The client has to process each of those chunks one after another.  If the
> server sends a chunk and the client encounters an error, there's nothing for
> the server to do; the client has no way to communicate it and it can just
> disconnect.  You would use requiresAnswer=False (as you are already doing in
> your case) to send a chunk of data like those entity-body chunks, which
> ought not to be a message that... requires an answer.  It's just a way of
> encoding some data on the connection.
>
> Make sense?

Yeah, especially in the context of a HTTP stream. In other words
requiresAnswer=False is just a way of labelling a messages as
'fire-and-forget'.

I'll have to think a bit more about which of my messages actually need
answers then. For some, I do need an indication of success (or
failure), if only so I can try re-sending. Those won't get the flag
then.




More information about the Twisted-Python mailing list