При парсинге валюты бот останавливается

Написал парсинг курсов валюты на aiohttp для своего бота на Python. При вводе команды 'биржа' оно выводит эти данные, но если ввести еще раз в консоль выводит: «Killed».

Код:

from app.bot import handler
from other_cmd import digit
from bs4 import BeautifulSoup
import aiohttp
from decimal import Decimal
from datetime import datetime

async def dollar_to_rub():
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'}
    dollar_to_Rub = 'https://www.google.com/search?q=%D0%BA%D1%83%D1%80%D1%81+%D0%B4%D0%BE%D0%BB%D0%BB%D0%B0%D1%80%D0%B0&oq=%D0%BA%D1%83%D1%80%D1%81+&aqs=chrome.1.69i57j0i131i433i512l4j69i61l3.2781j1j7&sourceid=chrome&ie=UTF-8'

    async with aiohttp.ClientSession() as session:
        response = await session.get(url=dollar_to_Rub, headers=headers)
        soup = BeautifulSoup(await response.text(), 'html.parser')
        dollar_currency = soup.findAll('span', {'class': 'DFlfde SwHCTb', 'data-precision': '2'})

    return Decimal(dollar_currency[0].text.replace(',', '.'))
async def euro_to_rub():
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'}
    dollar_to_Rub = 'https://www.google.com/search?q=%D0%BA%D1%83%D1%80%D1%81+%D0%B5%D0%B2%D1%80%D0%BE&oq=%D0%BA%D1%83%D1%80%D1%81+%D0%B5%D0%B2&aqs=chrome.1.69i57j0i131i433i512l3j0i512j0i131i433i512j0i512j0i433i512l2j0i3.2916j1j7&sourceid=chrome&ie=UTF-8'

    async with aiohttp.ClientSession() as session:
        response = await session.get(url=dollar_to_Rub, headers=headers)
        soup = BeautifulSoup(await response.text(), 'html.parser')
        euro_currency = soup.findAll('span', {'class': 'DFlfde SwHCTb', 'data-precision': '2'})

    return Decimal(euro_currency[0].text.replace(',', '.'))

async def btc_to_rub():
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'}
    dollar_to_Rub = 'https://www.google.com/search?q=%D0%BA%D1%83%D1%80%D1%81+%D0%B1%D0%B8%D1%82%D0%BA%D0%BE%D0%B8%D0%BD%D0%B0&oq=%D0%BA%D1%83%D1%80%D1%81+%D0%B1%D0%B8%D1%82%D0%BA&aqs=chrome.0.0i131i433i512j0i512j69i57j0i512j0i433i512j0i512l5.4321j1j7&sourceid=chrome&ie=UTF-8'

    async with aiohttp.ClientSession() as session:
        response = await session.get(url=dollar_to_Rub, headers=headers)
        soup = BeautifulSoup(await response.text(), 'html.parser')
        btc_currency = soup.findAll('span', {'class': 'pclqee'})
        btc_currency = btc_currency[0].text
        btc_currency = btc_currency.split()
        btc_currency = ''.join(btc_currency)

    return Decimal(btc_currency.replace(',', '.'))


@handler.message(name='биржа')
async def _(message, args, bot, user, chat, chat_user):
    do = datetime.now()
    text = f'{user.mention()}, биржа\n\n'

    text += 'Валюты: \n\n'
    text += f'? Доллар >> {await dollar_to_rub()}₽\n'
    text += f'? Евро >> {await euro_to_rub()}₽\n'

    text += '\n\nКриптовалюты: \n\n'
    text += f'? Биткоин >> {await btc_to_rub()}₽\n'
    await user.reply(text)
    await user.reply(f'Парсинг занял >> {datetime.now() - do}')


Ответы (0 шт):