The issue was posted several times here in stackoverflow, but none of them could help me as my case is very specific.
I have a function Myfunction(p1,p2,p3,p4) which need 4 parameters to run.
I need to run Myfunction on multiprocessing way.
I use concurrent.futures.ProcessPoolExecutor to do this job.
I know how to pass a list as an argument in the executor.map(Myfunction, argument)
But this time, I have a list of tuples which is the list of my 4 arguments for my multiprocessing.
Here is my code:
def Myfunction(p_udid,p_systemPort,p_deviceName, p_version, p_os):
desired_caps = {}
desired_caps['platformName'] = p_os
desired_caps['platformVersion'] = p_version
desired_caps['deviceName'] = p_deviceName
desired_caps['udid'] = p_udid
desired_caps['noReset'] = 'true'
if __name__ == '__main__':
list=[('41492968379078','4730','S6S5IN3G','6','Android'),('53519716736397','4731','S6S5IN3G','6','Android'),('0123456789ABCDEF','4732','20','7','Android')]
with concurrent.futures.ProcessPoolExecutor() as executor:
multiprocesses = executor.map(Myfunction, list)
Of course I get an error :
concurrent.futures.process._RemoteTraceback: """ Traceback (most recent call last): File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\concurrent\futures\process.py", line 239, in _process_worker r = call_item.fn(*call_item.args, **call_item.kwargs) File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\concurrent\futures\process.py", line 198, in _process_chunk return [fn(*args) for args in chunk] File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\concurrent\futures\process.py", line 198, in return [fn(*args) for args in chunk] TypeError: Myfunction() missing 4 required positional arguments: 'p_systemPort', 'p_deviceName', 'p_version', and 'p_os' """
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "E:/DropboxBACKUP14112018/Cff/Python/project_GITHUB/test2.py", line 24, in for multiprocess in multiprocesses: File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\concurrent\futures\process.py", line 483, in _chain_from_iterable_of_lists for element in iterable: File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\concurrent\futures_base.py", line 598, in result_iterator yield fs.pop().result() File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\concurrent\futures_base.py", line 435, in result return self.__get_result() File "C:\Users\Nino\AppData\Local\Programs\Python\Python37\lib\concurrent\futures_base.py", line 384, in __get_result raise self._exception TypeError: Myfunction() missing 4 required positional arguments: 'p_systemPort', 'p_deviceName', 'p_version', and 'p_os
I tried different stuff from all the answers similar to my issue, but I didn't succeed.
Can someone help me please?
Myfunction(*args). - stovfl*list, note the*, add aprint(args)at top ofMyfunction(*args)- stovfl