Skip to content

Commit

Permalink
change shm name format
Browse files Browse the repository at this point in the history
  • Loading branch information
lostsnow committed Jun 6, 2022
1 parent 6cf2eb2 commit 5cc1083
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dongtai_agent_python/setting/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def init_os_environ(self):

def set_shm(self, name):
if self.shm is None:
self.shm = SharedMemoryDict(name)
self.shm = SharedMemoryDict('dongtai-shm-python-' + name)

@property
def paused(self):
Expand Down
5 changes: 2 additions & 3 deletions dongtai_agent_python/utils/shm/shm.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ def __init__(self, name, size=1024):

@lock(_lock)
def get_or_create(self, size):
name = 'dongtai-shm-' + self.name
try:
return SharedMemory(name=name)
return SharedMemory(name=self.name)
except FileNotFoundError:
return SharedMemory(name=name, create=True, size=size)
return SharedMemory(name=self.name, create=True, size=size)

def init_memory(self):
memory_is_empty = (bytes(self.mem_block.buf).split(NULL_BYTE, 1)[0] == b'')
Expand Down

0 comments on commit 5cc1083

Please sign in to comment.