bpo-41344: raise ValueError when creating shared memory of size 0 by vinay0410 · Pull Request #21556 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/multiprocessing/shared_memory.py
12 changes: 12 additions & 0 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3878,6 +3878,18 @@ class OptionalAttachSharedMemory(shared_memory.SharedMemory):

sms.close()

# Test creating a shared memory segment with negative size
with self.assertRaises(ValueError):
sms_invalid = shared_memory.SharedMemory(create=True, size=-1)

# Test creating a shared memory segment with size 0
Comment thread
vinay0410 marked this conversation as resolved.
Outdated
with self.assertRaises(ValueError):
sms_invalid = shared_memory.SharedMemory(create=True, size=0)

# Test creating a shared memory segment without size argument
with self.assertRaises(ValueError):
sms_invalid = shared_memory.SharedMemory(create=True)

def test_shared_memory_across_processes(self):
# bpo-40135: don't define shared memory block's name in case of
# the failure when we run multiprocessing tests in parallel.
Expand Down