create global cookie jar after asyncio.run #7397
-
Hello! I am new to async programming in Python, and I have encountered a problem. I want to run a async function and then create a global cookie jar for different sessions. However, there would be a import asyncio
import aiohttp
async def func_1():
print("Just a test.")
class CoookieJarWrapper:
_cookie_jar: aiohttp.CookieJar
def __init__(self, jar):
self._cookie_jar = jar
def get_jar(self):
return self._cookie_jar
asyncio.run(func_1())
wrapper = CoookieJarWrapper(jar=aiohttp.CookieJar()) I need to both execute the async function and create a cookie jar. I am wondering if there are any best practices on that. Thx 🙏 . |
Beta Was this translation helpful? Give feedback.
Answered by
Dreamsorcerer
Jul 23, 2023
Replies: 1 comment
-
Typically, you run your code in a main() function or similar:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
RFYoung
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typically, you run your code in a main() function or similar: