This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author damian.barabonkov
Recipients damian.barabonkov, davin, gvanrossum, pablogsal, pitrou, vinay0410
Date 2020-08-06.15:52:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
As per Guido's comment (, I'm going to use this space to discuss ways to go forward with resource tracking and SharedMemory.

Taking inspiration from Vinay (, I think the simplest and best way forward is to use a small section of the shared memory at the start as a reference counter. 

Every time a process latches onto a shared memory block, it does and atomic increment to the reference counter. And if it detaches, it does an atomic decrement. This atomic operations are available in C via hardware specific instructions. This would require modifying the Python C code posixshmem.c. It should not be a difficult change.

This would then change the SharedMemory API such that a call to `close()` could check the reference count at the end, and aromatically unlink if it reaches 0. Basically, the purpose of the explicit `unlink()` call is dissolved.

I think this would also play nice with the current implementation of the `resource_tracker`. A small change would need to take place such that it calls `close()` instead of `unlink()` as the clean up function. Nonetheless, it would keep track if all attachments of shared memory call `close()` at the end, which they should, and issue a warning if they do not. It would do this with the current code, no need to change anything.
Date User Action Args
2020-08-06 15:52:25damian.barabonkovsetrecipients: + damian.barabonkov, gvanrossum, pitrou, davin, pablogsal, vinay0410
2020-08-06 15:52:24damian.barabonkovsetmessageid: <>
2020-08-06 15:52:24damian.barabonkovlinkissue38119 messages
2020-08-06 15:52:24damian.barabonkovcreate