[Twisted-Python] Switch Protocols mid Connection
I'm new to Twisted and really enjoying the event driven approach, especially with the availability of in-line callbacks to avoid callback hell. So thanks to all of you who have worked on Twisted. The program I'm writing uses AMP for peer to peer communication. I like AMP because it's natively asynchronous, has multi-language support, and efficient, not wasting resources on HTTP headers, etc. There are times when I need to send files, 1-2 MB over the connection. AMP provides a binary type, but it's limited to 64k, so I'd have to split the files up and make 16+ calls to transfer a single file. So I need to switch to a more appropriate (not yet determined) protocol for the transfer, and then back to AMP. AMP provides a protocol switch command, which is great, but then I'd need to switch back to AMP and I have no idea what approach to take here. It doesn't help that I don't have a file transfer protocol selected. Speaking of file transfer protocol , Twisted's FTP seems like overkill for my simple scenario, though if I could harness the functionality I need, I'd use it. I've also read up on Twisted's Producer/Consumer approach, which I'm thinking if I have to roll my own, this is the path I should take. However, I surely can't be the first person in more than a decade to want to transfer a file while speaking AMP. So, how do I switch back from a file transfer protocol to AMP and what existing protocol, if any, should I use for the transfer? Thanks so much. -Randall
On Sun, 16 Sep 2018 at 16:02, Randall Smith <randall@tnr.cc> wrote:
and make 16+ calls to transfer a single file. So I need to switch to a more appropriate (not yet determined) protocol for the transfer, and then back to AMP. AMP provides a protocol switch command, which is great, but then I'd need to switch back to AMP and I have no idea what approach to take here. It doesn't help that I don't have a file transfer protocol selected.
You might be able to get away with http://bazaar.launchpad.net/~glyph/%2Bjunk/amphacks/annotate/head%3A/python/...
On Sep 16, 2018, at 11:34 PM, Tristan Seligmann <mithrandi@mithrandi.net> wrote:
On Sun, 16 Sep 2018 at 16:02, Randall Smith <randall@tnr.cc> wrote:
and make 16+ calls to transfer a single file. So I need to switch to a more appropriate (not yet determined) protocol for the transfer, and then back to AMP. AMP provides a protocol switch command, which is great, but then I'd need to switch back to AMP and I have no idea what approach to take here. It doesn't help that I don't have a file transfer protocol selected.
You might be able to get away with http://bazaar.launchpad.net/~glyph/%2Bjunk/amphacks/annotate/head%3A/python/... <http://bazaar.launchpad.net/~glyph/+junk/amphacks/annotate/head:/python/amph...> You will also probably be interested in https://twistedmatrix.com/trac/ticket/9488 <https://twistedmatrix.com/trac/ticket/9488> .
-glyph
participants (3)
-
Glyph
-
Randall Smith
-
Tristan Seligmann