amosbastian / understat

An asynchronous Python package for https://understat.com/.
MIT License
150 stars 30 forks source link

Possible issue on Anaconda #31

Closed enadol closed 1 year ago

enadol commented 1 year ago

Hello! With...

import asyncio import json

import aiohttp

from understat import Understat

async def main(): async with aiohttp.ClientSession() as session: understat = Understat(session) data = await understat.get_league_players("epl", 2018, {"team_title": "Manchester United"}) print(json.dumps(data))

if name == "main": loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete(main())


I get the following

runfile('D:/undesstattest.py', wdir='D:') Traceback (most recent call last):

File "D:\undesstattest.py", line 19, in loop.run_until_complete(main())

File "D:\anaconda3\lib\asyncio\base_events.py", line 623, in run_until_complete self._check_running()

File "D:\anaconda3\lib\asyncio\base_events.py", line 585, in _check_running raise RuntimeError(

RuntimeError: Cannot run the event loop while another loop is running


The script is running on Anaconda through Spyder. Am I doint something wrong? Many tks.

amosbastian commented 1 year ago

What version of Python is it using?

enadol commented 1 year ago

Hello! It's running on Python 3.9.13.

Best regards,

jimjam8 commented 1 year ago

I had the same problem on anaconda and think it is because anaconda already runs an event loop. Found a post on stack overflow that suggested using nest-asyncio

Sent from my iPhone

On 16 May 2023, at 16:02, Enrique Lopez Magallon @.***> wrote:



Hello! It's running on Python 3.9.13.

Best regards,

— Reply to this email directly, view it on GitHubhttps://github.com/amosbastian/understat/issues/31#issuecomment-1549850332, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANPHHPB4KWKPGDHTBJCK55DXGOJINANCNFSM6AAAAAAYDMTB3Q. You are receiving this because you are subscribed to this thread.Message ID: @.***>

enadol commented 1 year ago

nest-asyncio was it! Tks!