pickle - Python multiprocessing: object identifier unique across processes -


Let's say that you want to run several processes in parallel (using multiprocusing, possibly on many different machines, such as in a cluster), where each process creates a list of new examples of a particular class, then you All these lists are sent back to the original process, and you want to add them. Now, can we index these examples from their object ID? Can I expect that the object can be identified specifically to the ID, because each object is generated on a different process (possibly a different machine)?

In other words, do data between the process of picking required to send the ID of an item, or whether interpreters provide fresh and exclusive IDs to the objects when they are unplickant? "post-text" itemprop = "text">

You asked, the object ID avoids snacking? There is no answer. The object is cooked and sent to another process, and a new object is created in that process with a new ID. The results are sent back to the original process. ID not alive? | Ids that are different objects do not usually sustain salt in the same process ?? Try obj2 = pickle.loads (pickle.dumps (object)) and see that is obj2 object ?? | This is not often the case.

  gt; & Gt; Import dell & gt; & Gt; & Gt; & Gt; & Gt; & Gt; Category A (object): ... pass ... & gt; & Gt; & Gt; B = A ()> & gt; & Gt; & Gt; & Gt; & Gt; & Gt; ID (B) 4473714832 & gt; & Gt; & Gt; ID (dill.loads (dill.dumps (b)) 4486366032 >> & gt; & gt;   

However, if you want to maintain an "id" So to understand what the object is, you can just do some ID information (a simple number, such as process "rank" (sequence), or some randomly generated hash, or something else Can you add a id attribute to store things? | You choose) If you make this feature ahead of time, If you store "ID" there, then he should keep this information across the pickle / However, if you dynamically id the attribute in any object If added, then pickle will be added to that attribute "forget" and that the deserialized object will not be attributed. Alternatively, if you have an "advanced" like dill If you use serializer, you can get a class instance or almost any ob Ekt you can create a dynamically added Atacitl from.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -