Skip to content

Commit fb9f500

Browse files
committed
making sure I only create a new buffer once
Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
1 parent 8bfa9ba commit fb9f500

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

receptor/buffers/file.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,11 @@ class FileBufferManager(BaseBufferManager):
103103
_buffers = {}
104104

105105
def get_buffer_for_node(self, node_id, receptor):
106-
path = os.path.join(os.path.expanduser(receptor.config.default_data_dir))
107-
return self._buffers.setdefault(node_id, DurableBuffer(path, node_id, asyncio.get_event_loop()))
106+
# due to the way that the manager is constructed, we won't have enough
107+
# information to build a proper defaultdict at the time, and we want to
108+
# make sure we only construct a single instance of DurableBuffer
109+
# per-node so.. doing this the hard way.
110+
if node_id not in self._buffers:
111+
path = os.path.join(os.path.expanduser(receptor.config.default_data_dir))
112+
self._buffers[node_id] = DurableBuffer(path, node_id, asyncio.get_event_loop())
113+
return self._buffers[node_id]

0 commit comments

Comments
 (0)