Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Passing multiple arguments to a method is failing #19

Closed
Arjunsankarlal opened this issue Jul 1, 2020 · 3 comments
Closed

Passing multiple arguments to a method is failing #19

Arjunsankarlal opened this issue Jul 1, 2020 · 3 comments

Comments

@Arjunsankarlal
Copy link

I am using starmap method in ZPool for passing multiple arguments, which is the same method we would be using in the multiprocessing library, but here when I pass the values as mentioned, it is failing and running infinitely!

A simple example code I am using is,

import fiber
from fiber.pool import Pool


@fiber.meta(cpu=1)
def add(a, b):
    return a + b


if __name__ == "__main__":
    pool = Pool(processes=4)
    ans = pool.starmap(add, [(1, 2), (4, 5)])

The exception I am getting is,

Exception in Process(PoolWorker-4, 24266)>:
Traceback (most recent call last):
File "/Users/arjun/environments/fibertest/lib/python3.6/site-packages/fiber/process.py", line 289, in _bootstrap
self.run()
File "/Users/arjun/environments/fibertest/lib/python3.6/site-packages/fiber/process.py", line 185, in run
return super().run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/Users/arjun/environments/fibertest/lib/python3.6/site-packages/fiber/pool.py", line 858, in zpool_worker
wrap_exception, 0, req=req)
File "/Users/arjun/environments/fibertest/lib/python3.6/site-packages/fiber/pool.py", line 801, in zpool_worker_core
res = func(*args, **kwds)
TypeError: add() argument after ** must be a mapping, not tuple

And it is being printed indefinitely!

I am doing something wrong here ? Or is this an issue ?

@calio
Copy link
Collaborator

calio commented Jul 1, 2020

Thanks for reporting this error. It seems to be a bug in handling starmap when chunksize is not 1. I'll create a fix for it later. In the mean time, you can set the chunksize argument of starmap to 1 explicitly work around this bug. For example:

pool.starmap(add, [(1, 2), (4, 5)], 1)

@calio
Copy link
Collaborator

calio commented Aug 21, 2020

This issue has been fixed in #32. Could you install the current master version and verify it?

@calio
Copy link
Collaborator

calio commented Feb 24, 2021

Close due to lack of activity.

@calio calio closed this as completed Feb 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants