Когда большие данные: Requests.Exceptions.ConnectionError: («Соединение прервано.», RemoteDisconnected («Удаленное заверPython

Программы на Python
Ответить
Anonymous
 Когда большие данные: Requests.Exceptions.ConnectionError: («Соединение прервано.», RemoteDisconnected («Удаленное завер

Сообщение Anonymous »

Проблема возникает, когда у меня есть большое количество значений в моем pandas df. Когда я беру 27 или 54 значения (1 или 2 столбца), это работает нормально, но когда я беру больше столбцов, это дает мне эту ошибку (я импортирую класс gs из другого файла.
Код и проблема:

Код: Выделить всё

Traceback (most recent call last):
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 789, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request
response = conn.getresponse()
^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connection.py", line 464, in getresponse
httplib_response = super().getresponse()
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1428, in getresponse
response.begin()
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 331, in begin
version, status, reason = self._read_status()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 300, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 843, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\retry.py", line 474, in increment
raise reraise(type(error), error, _stacktrace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\util.py", line 38, in reraise
raise value.with_traceback(tb)
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 789, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request
response = conn.getresponse()
^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connection.py", line 464, in getresponse
httplib_response = super().getresponse()
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1428, in getresponse
response.begin()
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 331, in begin
version, status, reason = self._read_status()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 300, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError:  ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "d:\albautoorder\scripts\main.py", line 426, in 
upd_values(gt,gr,cty,tierss,enchantss)
File "d:\albautoorder\scripts\main.py", line 420, in upd_values
ws.update(payload, value_input_option = 'user_entered')
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\gspread\worksheet.py", line 1246, in update
response = self.client.values_update(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\gspread\http_client.py", line 173, in values_update
r = self.request("put", url, params=params, json=body)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\gspread\http_client.py", line 114, in request
response = self.session.request(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\google\auth\transport\requests.py", line 540, in request
response = super(AuthorizedSession, self).request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexk\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 682, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
PS D:\albautoorder>

Код: Выделить всё

def upd_values(gt,group,city,tiers: list,enchants: list):
time.sleep(3)
df = gt.get_all_data(city)
item_lst = groups.get(group)
item_lst_gs = groups_gs.get(group)
df_name = df[df["Item"].isin(item_lst_gs)].copy()
for i in range(len(tiers)):
for y in range(len(enchants)):
mo.filter_item(tiers[i], enchants[y])
for x in range(len(item_lst)):
inp_t = f"T{tiers[i]}.{enchants[y]}"
print(item_lst[x])
if item_lst_gs[x] not in df["Item"].values:
print(f"Не найден предмет:  {item_lst_gs[x]}")
item_price = find_and_open(item_lst[x],city,tiers[i],enchants[y])
print (item_price)
df_name.loc[df["Item"] == item_lst_gs[x],inp_t ] = item_price
headers = df_name.columns.tolist()
values = df_name.values.tolist()
print(headers)
print(values)
payload = [headers]+values
print(payload)
ws = gt.sheets[city]
ws.update(payload, value_input_option = 'user_entered')
gr = "NArt_Arm"
cty = "Lymhurst"
tierss = [5,6]
enchantss = [2,3]
gt = gs.GoogleTable("token")
upd_values(gt,gr,cty,tierss,enchantss)
полезная нагрузка:
[['Item', 'T4.0', 'T4.0_amount', 'T4.1', 'T4.1_amount', 'T4.2', 'T4.2_amount', 'T4.3', 'T4.3_amount', 'T5.0', 'T5.0_amount', 'T5.1', 'T5.1_сумма', 'T5.2', 'T5.2_сумма', 'T5.3', 'T5.3_сумма', 'T6.0', 'T6.0_сумма', 'T6.1', 'T6.1_сумма', 'T6.2', 'T6.2_сумма', 'T6.3', 'T6.3_сумма', 'T7.0', 'T7.0_сумма', 'T7.1', 'T7.1_сумма', 'T7.2', 'T7.2_сумма', 'T7.3', 'T7.3_сумма', 'T8.0', 'T8.0_сумма', 'T8.1', 'T8.1_сумма', 'T8.2', 'T8.2_amount', 'T8.3', 'T8.3_amount'], ['Soldier_Boots', 2490, '', 4500, '', 17302, '', '', '', 5695, '', 11751, '', '44588', '', '118000', '', 11384, '', 39499, '', '114998', '', '324999', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Knight_Boots', 1493, '', 2221, '', 19960, '', '', '', 4982, '', 7988, '', '28104', '', '79999', '', 9285, '', 22997, '', '96992', '', '309992', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Guardian_Boots', 996, '', 2100, '', 14994, '', '', '', 4950, '', 11834, '', '', '', '99987', '', 11969, '', 26994, '', '99999', '', '309985', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Soldier_Armor', 2479, '', 3888, '', 26880, '', '', '', 8994, '', 10899, '', '50956', '', '240000', '', 19000, '', 47984, '', '233990', '', '799998', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Knight_Armor', 2499, '', 3995, '', 25000, '', '', '', 9895, '', 13145, '', '43497', '', '219995', '', 23806, '', 40510, '', '232945', '', '749998', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Guardian_Armor', 2988, '', 3500, '', 21844, '', '', '', 7893, '', 14208, '', '35898', '', '244996', '', 22193, '', 35998, '', '229998', '', '799854', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Soldier_Helmet', 6986, '', 9812, '', 19280, '', '', '', 2498, '', 9999, '', '41995', '', '150887', '', 15088, '', 27995, '', '129991', '', '394435', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Knight_Helmet', 1788, '', 2065, '', 7999, '', '', '', 3411, '', 7893, '', '24781', '', '117960', '', 14490, '', 19999, '', '552458', '', '289998', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Guardian_Helmet', 1090, '', 3744, '', 17481, '', '', '', 3810, '', 12953, '', '33310', '', '134436', '', 14999, '', 31938, '', '116000', '', '339946', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Mercenary_Shoes', 1193, '', 2370, '', 22976, '', '', '', 3999, '', 17000, '', '42983', '', '164999', '', 23987, '', 41094, '', '137986', '', '333328', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Hunter_Shoes', 1880, '', 2690, '', 19885, '', '', '', 4983, '', 13591, '', '38850', '', '148998', '', 21496, '', 46790, '', '109997', '', '320000', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Assassin_Shoes', 1838, '', 2449, '', 20999, '', '', '', 4196, '', 19415, '', '40899', '', '167765', '', 24973, '', 42999, '', '115970', '', '334880', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Mercenary_Jacket', 2394, '', 4850, '', 34487, '', '', '', 10466, '', 28985, '', '76787', '', '250000', '', 35949, '', 84991, '', '259878', '', '749988', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Hunter_Jacket', 2995, '', 4029, '', 33856, '', '', '', 10295, '', 18879, '', '40970', '', '230000', '', 39981, '', 53996, '', '199999', '', '647999', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Assassin_Jacket', 3061, '', 6682, '', 30977, '', '', '', 10894, '', 23425, '', '82000', '', '309987', '', 38959, '', 79998, '', '267989', '', '769997', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Mercenary_Hood', 1492, '', 2323, '', 11996, '', '', '', 6970, '', 14797, '', '29989', '', '129988', '', 24800, '', 28999, '', '99997', '', '309999', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Hunter_Hood', 1998, '', 3269, '', 17836, '', '', '', 6999, '', 16245, '', '37900', '', '114998', '', 20997, '', 40990, '', '114933', '', '359980', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Assassin_Hood', 1992, '', 1994, '', 22949, '', '', '', 6875, '', 24892, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Scholar_Sandals', 844, '', 1668, '', 12999, '', '', '', 3730, '', 8099, '', '30945', '', '124993', '', 12196, '', 27760, '', '96993', '', '332996', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Cleric_Sandals', 915, '', 1656, '', 13999, '', '', '', 3373, '', 7980, '', '25987', '', '136981', '', 12000, '', 27959, '', '95000', '', '388886', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Mage_Sandals', 927, '', 1682, '', 15499, '', '', '', 2402, '', 7000, '', '88', '', '110000', '', 11183, '', 27430, '', '95994', '', '311107', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Scholar_Robe', 1385, '', 2112, '', 22994, '', '', '', 9391, '', 14995, '', '38995', '', '237995', '', 27997, '', 49990, '', '209995', '', '698868', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Cleric_Robe', 1473, '', 3979, '', 26947, '', '', '', 7894, '', 28866, '', '44982', '', '250994', '', 26891, '', 64828, '', '209956', '', '670840', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Mage_Robe', 1977, '', 2055, '', 37425, '', '', '', 8990, '', 34974, '', '50999', '', '229996', '', 29977, '', 52457, '', '150000', '', '589991', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Scholar_Cowl', 2291, '', 4294, '', 16992, '', '', '', 4397, '', 18999, '', '34128', '', '111942', '', 11957, '', 27814, '', '116895', '', '319997', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Cleric_Cowl', 2969, '', 4347, '', 23987, '', '', '', 6254, '', 17499, '', '22500', '', '159987', '', 15545, '', 22998, '', '109280', '', '338887', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], ['Mage_Cowl', 2329, '', 5675, '', 38982, '', '', '', 5919, '', 14090, '', '31041', '', '119338', '', 15999, '', 21000, '', '109981', '', '309989', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']]

Подробнее здесь: https://stackoverflow.com/questions/798 ... borted-rem
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»