3 ms·
Pickling generators is one step from being able to pickle a continuation or save the state of a running function. This is actually a useful thing to do. I wrote
by raffi 17y ago
Pickling generators is one step from being able to pickle a continuation or save the state of a running function. This is actually a useful thing to do. I wrote a script awhile that spawned several processes that each required posting multiple jobs to Mechanical Turk and doing so in a certain sequence. My language Sleep supports continuations (and generators) and allows me to serialize (pickle) my continuations. I just spawned off a thread for each "process" and periodically saved that executing function to disk. Later when I wanted to restart the program, it'd look on disk for the saved functions, load them, and execute them. Very fun.
I wrote on article about how to do this kind of stuff awhile back:
http://today.java.net/pub/a/today/2008/07/24/fun-with-continuations.html http://today.java.net/pub/a/today/2008/07/24/fun-with-contin...