'How to pass async function to Pool.map()?
The following code will get the error of
multiprocessing.pool.MaybeEncodingError: Error sending result: '[<coroutine object f at 0x000001EA90528CC0>]'. Reason: 'TypeError("cannot pickle 'coroutine' object")'
from multiprocessing import Pool
async def f(x): # removing async works
return x * x
if __name__ == '__main__':
with Pool(3) as p:
print(p.map(f, [1,2,3]))
How to use Pool.map with asynchronous function?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
