From 01bec9900adfdbdcd49d5e2a3bdd59dc4b242616 Mon Sep 17 00:00:00 2001 From: Katie May Date: Tue, 7 Jul 2026 15:47:34 +0200 Subject: [PATCH] add example failure and how to remedy for shared-memory interface --- .../interfaces/shared-memory-interface.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/reference/interfaces/shared-memory-interface.md b/docs/reference/interfaces/shared-memory-interface.md index 25c753a..17c25a7 100644 --- a/docs/reference/interfaces/shared-memory-interface.md +++ b/docs/reference/interfaces/shared-memory-interface.md @@ -69,3 +69,31 @@ The test code can be found in the snapd repository: The source code for the interface is in the snapd repository: [shared_memory.go](https://github.com/canonical/snapd/blob/master/interfaces/builtin/shared_memory.go)
+### Common issues + +#### Semaphore errors in Python + +When using the interface in non-private mode with multi-processing Python, one might encounter something like this: +``` +ProcessPoolExecutor(max_workers=max_workers) as executor: +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +File "/opt/python/lib/python3.11/concurrent/futures/process.py", line 732, in __init__ +self._call_queue = _SafeQueue( +^^^^^^^^^^^ +File "/opt/python/lib/python3.11/concurrent/futures/process.py", line 173, in __init__ +super().__init__(max_size, ctx=ctx) +File "/opt/python/lib/python3.11/multiprocessing/queues.py", line 43, in __init__ +self._rlock = ctx.Lock() +^^^^^^^^^^ +File "/opt/python/lib/python3.11/multiprocessing/context.py", line 68, in Lock +return Lock(ctx=self.get_context()) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +File "/opt/python/lib/python3.11/multiprocessing/synchronize.py", line 169, in __init__ +SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx) +File "/opt/python/lib/python3.11/multiprocessing/synchronize.py", line 57, in __init__ +sl = self._semlock = _multiprocessing.SemLock( +^^^^^^^^^^^^^^^^^^^^^^^^^ +PermissionError: [Errno 13] Permission denied` +``` + +The error comes from Python semaphores attempting to access /dev/shm. To remedy, use private mode instead that bind-mounts a snap-private /dev/shm and then grants access to all of it.