Run1e/asyncspotify

authorize issue

Closed this issue · 1 comments

what am i doing wrong. i think im doing it exactly how the docs told me

async def main():

auth = ClientCredentialsFlow(
client_id='my id',
client_secret=os.getenv('sp'))

sp = Client(auth)
await sp.authorize()

asyncio.run(main())

and it says:
RuntimeError: There is no current event loop in thread 'MainThread'.

Run1e commented

Hi,

Try replacing asyncio.run(main())

with

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.run_forever()

I think this issue is occurring since after completing the main() coroutine the loop tears down even though there's most tasks that need to be run.