I'm trying to achieve a mechanism to "fire and Forget" My request and return to the call function, but my function always waits for the responses.
import requests
class Res():
def process_data(self, data):
# some data process
plan = {'data':'test'}
# Fire and Forget i dont care about the return value
asyncio.run(self.fire(plan))
# Im tryting to return the response before the response from the above call
response = {'rid': '12345'}
return response
async def fire(self,message):
print("async_foo done")
payload = json.dumps(message, indent=4, default=lambda x: x.__dict__)
headers = {'content-type': 'application/json'}
async with aiohttp.ClientSession() as session:
async with session.post(RUNTIME_URL, data=payload, headers=headers) as resp:
print(resp.status)
print(await resp.text())
Can some one help, im not sure what im missing here.