FIXED Asynchronous OOP HTTP requests Python
I'm trying to make a class to interact with a database server (which I have already written and works), but I do not know enough about async programming to understand why I am getting this error, so help would be appreciated.
It runs better from a synchronous context, with
which creates the client and gets as far as
run and then
makeRequest, before raising
RuntimeError: Event loop is closed when it tries to make the actual request (
async with self.httpSession.post(self.url, json = data) as req in
however in an async context
it raises multiple errors, (
RuntimeError: asyncio.run() cannot be called from a running event loop and
UnboundLocalError: local variable 'client' referenced before assignment).
This is less than ideal, as eventually I am intending to use it from an asynchronous context (a discord bot)
Also if anybody has any suggestions about the todo on line 105 that would be useful