Skip to content

Can't get the example Pool code to work #183

@Deville-ee

Description

@Deville-ee

Description

I can't execute the example code in the Process section. Both the apply() method as the map(math.sqrt) method.

Documentation

I've managed to get the math.sqrt working but not like indicated in the example. I moved the math.sqrt call to an asyncio aware section because if I don't, the interpreter complains about exactly this.

TypeError: An asyncio.Future, a coroutine or an awaitable is required

Edit: To be complete : I'm getting following error when using the apply() method:

RuntimeError: await wasn't used with future

_
My adaptation for the sqrt example:

import asyncio
import math
from aiomultiprocess import Pool


async def sqrt_task(data):
    return math.sqrt(data)


async def main():
    async with Pool() as pool:
        data = [1, 4, 9, 16, 25]
        results = await pool.map(sqrt_task, data)
        print(results)


if __name__ == '__main__':
    asyncio.run(main())

Details

  • OS: Ubuntu 22.04.1 LTS
  • Python version: 3.7.10
  • aiomultiprocess version: 0.9.0
  • Can you repro on master?
  • Can you repro in a clean virtualenv?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions