Get the latest tech news

Python and SysV Shared Memory


At work-work the system uses, for historical reasons, a lot of SystemV shared memory. The SysV shared memory API has C functions like shmat(2). There is also a different shared memory API, POSIX shared memory, which has functions like shm_open(3). For reasons, on some work-work systems we’re constrained to Python 3.7 and no additional libraries. I wanted to mess with the shared memory on such a system, from Python for convenience, so I wrote some very simple wrappers. Here’s a recap.

I wanted to mess with the shared memory on such a system, from Python for convenience, so I wrote some very simple wrappers. The following snippet is then sufficient to create a shared memory segment (one that is 1024 bytes large and world-readable) and print out its ID. The ID can be cross-checked with command ipcs -m(it’s installed by default on FreeBSD and in my KDE Neon machine, so seems like a common tool).

Get the Android app

Or read this on Hacker News

Read more on:

Photo of python

python

Photo of SysV Shared Memory

SysV Shared Memory

Related news:

News photo

Started a guide to writing FUSE filesystems in Python

News photo

Napkin: Back-of-the-envelope calculations in Python

News photo

The Ultimate Guide to Error Handling in Python