I have looked at previous answers and none of them seem to solve my issue. I am running the below code
from pyracing.client import Client
import asyncio
username = 'My Email Address'
password = 'My Password'
# Authentication is automated and will be initiated on first request
ir = Client(username, password)
# Example async function with hardcoded results
async def main():
seasons_list = await ir.current_seasons()
for season in seasons_list:
if season.season_id == 2846:
print(f'Schedule for {season.series_name_short}'
f' ({season.season_year} S{season.season_quarter})')
for t in season.tracks:
print(f'\tWeek {t.race_week} will take place at {t.name} ({t.config})')
asyncio.run(main())
and I get the below error:
RuntimeError Traceback (most recent call last)
Cell In[1], line 23
20 for t in season.tracks:
21 print(f'\tWeek {t.race_week} will take place at {t.name} ({t.config})')
---> 23 asyncio.run(main())
File ~\AppData\Local\anaconda3\Lib\asyncio\runners.py:191, in run(main, debug, loop_factory)
161 """Execute the coroutine and return the result.
162
163 This function runs the passed coroutine, taking care of
(...)
187 asyncio.run(main())
188 """
189 if events._get_running_loop() is not None:
190 # fail fast with short traceback
--> 191 raise RuntimeError(
192 "asyncio.run() cannot be called from a running event loop")
194 with Runner(debug=debug, loop_factory=loop_factory) as runner:
195 return runner.run(main)
RuntimeError: asyncio.run() cannot be called from a running event loop
what is am trying to eliminate is teh runtime error issue
main(). Always put correctly formatted code.