I don’t see where in your code the count var is first initialised?
Please provide a full code sample and also the version of the Python client being used.
Adding some debug prints to make sure the loop actually iterates over all chunkfiles and looking at the requests being made on the server side will also be helpful.
As reference, you can see a full implementation that uses the Java client here:
This can be run from CLI.
The more relevant code for this operation is here: