For what I read it seems that generators cannot be copied or pickled, this can be a persistent headache for usual generator users:
Here a small selection of post in different pages with related issues and ideas:
tldr:
Generators are problematic if passed to a multiprocessing worker, or any python functionality that relies in pickling, they cannot be saved and loaded in any manner that i know, and they can not be bifurcated (itertools.tee only solves the issue if the generator doesn’t implement the send method, is not async, and in general is a idyllically behaved generator).
I saw that there is some reasons for this, but I was wondering if there is any new workaround or perspective of changing this? For what i read it should be possible, some implementations like pypy are able to do it already.
For what I see being able to copy-pickle a generator will solve many seemingly unrelated issues.