I'm encountering some strange behavior in my python program. I'm using a Pool
to run some functions in parallel and using the apply_async
function. The strange behavior is that, apparently, significantly more arguments are being passed to the function than should be passed. It's likely something silly, but here is the relevant context:
def do_joesecurity_analysis(filename: str):
# Stuff
...
return;
...
def do_analysis(args):
...
pool = Pool();
for dirpath, dirnames, filenames in os.walk(directory):
for f in filenames:
...
print( type(f) );
start_analysis = pool.apply_async(do_joesecurity_analysis, args = (f) );
The error I get is:
TypeError: do_joesecurity_analysis() takes 1 positional argument but 64 were given
Now, the length of the filename happens to be 64 characters long (it's a combination of letters and numbers), and that debugging print
statement says <class 'str'>
, so I'm confused as to why it seems to treat each character as an argument.
Note: Just to make sure that I wasn't going crazy, I made a normal function call to do_joesecurity_analysis(f)
(i.e. not in a Pool
), and the function ran perfectly.
If it's relevant, the interpreter I'm using is version 3.9.1.
If necessary, I will provide additional information.
Thanks!