#python #multithreading #python-asyncio #aiohttp #oserror
#питон #многопоточность #python-asyncio #aiohttp #ошибка
Вопрос:
У меня есть приложение на Python, которое очень хорошо работает на моем компьютере (моя операционная система Windows 10 — 64-разрядная). Но когда я переношу приложение и его папку на компьютер с версией операционной системы Windows 8, возникла такая ошибка:
«Ошибка ОС(22,»Операция ввода-вывода имеет либо выход из потока, либо запрос приложения», Нет)
Исключение задачи так и не было получено»
Вот коды для моего приложения, не могли бы вы, пожалуйста, помочь мне с этой проблемой?
Кроме того, когда я закрываю окно графического интерфейса, всегда отображается ошибка: «Ошибка выполнения: цикл событий закрыт».
import PySimpleGUI as sg import requests import concurrent.futures import aiohttp import asyncio import time # This is the GUI and GUI event loop: layout = [[sg.Text('Input the collection IDEE here: '), sg.Input(key='-IN-')], [sg.Text(key='-OUT-', text_color="Red")], [sg.Button('OK'), sg.Button('Exit')]] window = sg.Window('Asset Collector', layout) while True: event, values = window.read() if event is None or event == 'Exit': break window['-OUT-'].update(values['-IN-']) # Get the collection info: contract address, total supply: idee = values['-IN-'] url_1 = "https://api.thisoneisconfidential.co/api/v1/collection/" idee response_1 = requests.request("GET", url_1) collection = response_1.json() contract_address = collection["collection"]["primary_asset_contracts"][0]["address"] supply = int(collection["collection"]["stats"]["total_supply"]) # Materials for the calls: url = 'https://api.thisoneisconfidential.co/api/v1/assets?order_direction=ascamp;offset={}amp;limit=50amp;collection={}' offsets = [] results = [] num = 0 # Get the list of offsets for each call: while num lt; supply: offsets.append(str(num)) num = 50 def get_tasks(session): tasks = [] for offset in offsets: tasks.append(asyncio.create_task(session.get(url.format(offset, idee), ssl=False))) return tasks async def get_symbols(): async with aiohttp.ClientSession() as session: tasks = get_tasks(session) responses = await asyncio.gather(*tasks) for response in responses: asset = await response.json() a = asset['assets'] def get_token_ids(an): if str(an['sell_orders']) == 'None' and str(an['last_sale']) == 'None' and str(an['num_sales']) == '0': results.append(str(an['permalink'])) with concurrent.futures.ThreadPoolExecutor() as executor: output = [executor.submit(get_token_ids, item) for item in a] asyncio.run(get_symbols()) print(results) # Create CSV file of asset links result = open(idee " collection.csv", 'w') for link in results: result.write(link "n") result.close() window.close()