aiomultiprocess icon indicating copy to clipboard operation
aiomultiprocess copied to clipboard

_pickle.PicklingError: Can't pickle <function get at 0x12cb5ea60>: attribute lookup get on __main__ failed

Open yuanjie-ai opened this issue 2 years ago • 1 comments
trafficstars

Description

import asyncio
from aiohttp import request
from aiomultiprocess import Pool  # todo


async def get(url):
    async with request("GET", url) as response:
        return await response.text("utf-8")


async def mainmain():
    urls = ["https://www.baidu.com"]*10
    async with Pool() as pool:
        results = await pool.map(get, urls)

        return results


if __name__ == '__main__':
    # Python 3.7
    asyncio.run(mainmain())

Details

  • OS: macos
  • Python version: 3.8
  • aiomultiprocess version: 0.9
  • Can you repro on master?
  • Can you repro in a clean virtualenv?

yuanjie-ai avatar Jul 04 '23 01:07 yuanjie-ai

In the sample, there is some code that cannot be compiled normally. Did the author not test each piece individually when writing the documentation?

allrobot avatar Jun 07 '24 02:06 allrobot