B
B
Bl4ckm45k2020-09-02 01:44:35
Python
Bl4ckm45k, 2020-09-02 01:44:35

How to deal with repeated GET request?

Every minute to the server, I send a get request. I
process it like this

def in_work():
        response_work = requests.get(url + param + work, verify=False)
        response_work.encoding = "utf-8"
        data_work = response_work.json()
        print(url + param + work)
        for x in data_work:
           for y in x["data"]:
              if y["status"] in ["27047"]:
                 Change_w = requests.get(
                            url1 + '27047')
                  Change_w.encoding = "utf-8

Is it possible to somehow break the loop if y["status"] is repeated in a request sent a minute before?
Thank you all for your attention. Or simply do not send a GET request if there has already been an identical one

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2020-09-02
@leahch

Can! Install redis. Push status into it with TTL equal to two minutes.
First check if redis has a status value and return it either from the redis or via a query.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question