multithreading - Python: how to use pickle to dump Queue objects? -
the problem directly using pickle dump queue raise exception. have read similar post not got answer yet: pickle queue objects in python
i can't replace queue collections.deque because i'm running multithreading program, in queue used synchronization.
so how can this?
if need save queue remaining content the (one , one) master thread after consumer , producer threads have terminated, have dump queue plain of list -- , use pickle persist list.
def qdumper(q): try: yield q.get(false) except queue.empty: pass remaining = [item item in qdumper(my_queue)] pickle.dump(remaining, ....)
Comments
Post a Comment