Python multithreaded put () queue

I am doing something very simple using multiprocessing:

data = {'a': 1}
queue.put(data, True)
data.clear()

When I use a queue on another process (using a method get()), I get an empty dictionary. If I delete data.clear(), I will get the keys as expected. Is there any way to wait for the put()serialization to complete ?

+4
source share
2 answers

, , . , , , " contue queue".

, :

  • , ? , , , dict.clear() ?

  • ; : a_queue.put(pickle.dumps(data)) pickle.loads(a_queue.get()). , data.clear() put, "".

( , ), , , .

+4

, , data . :

data = {'a': 1}
dc = data.copy()
queue.put(dc)
data.clear()

, , , . dc , .

+2

All Articles