Skip to content Skip to sidebar Skip to footer

Get Continuous Response Of Post Request In Python

I'm writing a script which does a POST request to a server and gets blocked the server keeps sending the response whenever a specific event is triggered. I have to take a cookie fo

Solution 1:

I've fixed this problem with two level threading and reading chunks instead of content or read_lines(). 1] First threads will be created which will spawn second thread and run keepalive when timeout hits.

2]Second thread subscribes to event with POST request and then keeps on listening to chunks of size 1024 everytime a response is received it is parsed and respective data is updated. Here I used requests with Stream=True; This wasn't working for me earlier because cookie used to expire before reading response and session used to close.

If someone has better way to do this please update here.

Post a Comment for "Get Continuous Response Of Post Request In Python"