MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / put

Method put

CV/PaddleReid/reid/data/shared_queue/queue.py:65–82  ·  view source on GitHub ↗

put an object to this queue

(self, obj, **kwargs)

Source from the content-addressed store, hash-verified

63 capacity=memsize, pagesize=pagesize)
64
65 def put(self, obj, **kwargs):
66 """ put an object to this queue
67 """
68 obj = pickle.dumps(obj, -1)
69 buff = None
70 try:
71 buff = self._shared_mem.malloc(len(obj))
72 buff.put(obj)
73 super(SharedQueue, self).put(buff, **kwargs)
74 except Exception as e:
75 stack_info = traceback.format_exc()
76 err_msg = 'failed to put a element to SharedQueue '\
77 'with stack info[%s]' % (stack_info)
78 logger.warn(err_msg)
79
80 if buff is not None:
81 buff.free()
82 raise e
83
84 def get(self, **kwargs):
85 """ get an object from this queue

Callers 5

_produceMethod · 0.45
_consumeMethod · 0.45
stopMethod · 0.45
nextMethod · 0.45
taskMethod · 0.45

Calls 2

mallocMethod · 0.80
freeMethod · 0.45

Tested by

no test coverage detected