[Twisted-Python] HTTP PUT a GET's streaming response with treq

Nagy, Attila bra at fsn.hu
Thu May 4 07:32:24 MDT 2017


On 05/04/2017 03:04 PM, Phil Mayers wrote:
> On 04/05/17 13:04, Nagy, Attila wrote:
>> Hi,
>>
>> I would like to copy a file between two HTTP servers in the most 
>> efficient manner, which probably means a streaming down/upload 
>> (GET/PUT) with the producer/consumer scheme.
>>
>> Can this be done easily, could somebody write a simple example?
>
> I guess it'll look something like this:
>
> https://gist.github.com/philmayers/692d04c15a71d3905e075b30f0543f23
>
> Only lightly tested, but seems to work. There's a lot of debugging 
> print statements in the above code which can obviously be discarded or 
> turned into logging statements in production use.
In the meantime I've started to write one and came out with this:
https://gist.github.com/bra-fsn/42e556ddd74ff34467b17b9a6d613b33

Are there any problems with this approach?




More information about the Twisted-Python mailing list