The following code does work in python 3.7, but it doesn't work in python 3.8 (AttributeError: Can't pickle local object 'main.<locals>.f')
import multiprocessing as mp
import asyncio
async def main():
def f():
print("hello")
p = mp.Process(target=f)
p.start()
if __name__ == "__main__":
asyncio.run(main())
I know that running a process inside an async function is not a common thing and might raise a few eyebrows, but I've found it useful sometimes. What is the reason it doesn't work in python 3.8 anymore? Is there a way to update the code to make it work?