Why does it stop sending after sending several requests and no response is received in Python?

Viewed 25

When I execute the following code, the requests are sent and the result is received, but after sending several requests, no more requests are sent, as if the program stops. I am not getting any error

I don't know where the problem is

I would be grateful if someone could help me

async def get_data():
    global data_list,temp
    global counter

    
    counter=1
    while True:
        user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
        headers = {'Connection': 'close','User-Agent':user_agent }

        r = requests.get(url,headers=headers)

        else:
            counter += 1
            print("Number Of Requests : ",counter)
            main_txt = r.text
            csvs = main_txt.split('@')
            main_csv = csvs[2]
            csv = main_csv.split(';')
            rows = [row.split(',') for row in csv]
            data_list.clear()
            for i in range(len(rows)):
                if rows[i][22] in stock_keys:
                    data_list += [
                        rows[i][1:2] + list(map(float, rows[i][7:8]))
                        ]
            signal(data)
            r.close()
        await asyncio.sleep(1)
0 Answers
Related