> Is it worth broadening out the discussion to other sorts of named objects?  
> Named Pipes particularly spring to my mind...

The main reason why I requested this enhancement was to ensure that multiple 
processes can read/write a shared memory segment without corrupting that data 
in it.

To ensure the same shared semaphores came to mind. Each shared memory segment, 
can have a corresponding shared semaphore.

I don't think using named pipes would be a good way to ensure the same. 
Although, if you think otherwise please suggest so.

I also thought keeping a semphore inside the shared memory segment would be 
much cleaner and easier to do, but unfortunately macos has deprecated sem_t.

Other ways include storing an integer in the shared memory segment, which could 
be altered via atomic operations, this integer can be used as a counting 
semaphore.

Python uses the following atomic operations to implement GIL, which can also be 
used above.

https://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html

Also, the reason for asking named shared semaphore's was that they already 
exist in python library, but they are cleaned up, as soon as the process which 
created them dies. 

Since, macos has deprecated sem_t, the Semaphore in multiprocessor.synchronize 
uses SemLock class which in turn uses named semaphores, the only issue is that 
these semaphores are erased as soon as the process which created them dies.

Therefore, I thought it would be much easier to provide a public API to use 
named semaphores, since they are already implemented, after a few changes of 
course.

> On 09-Jun-2020, at 10:32 PM, Rhodri James <rho...@kynesim.co.uk> wrote:
> 
> On 09/06/2020 17:16, Vinay Sharma wrote:
>> Hi,
>> I posted this here because a core Developer (Tal Einat), asked me to, 
>> although I am not sure what is the protocol from here. Does this enhancement 
>> request look reasonable ?
>> If yes, I would love to open a PR.
>> If not, any suggestions, feedback is very welcome.
> 
> I've been thinking about this for a couple of days now, and I think for what 
> little it's worth my answer is mostly yes.  You're basically asking for Named 
> Semaphores, which are a perfectly sensible thing to want for inter-program 
> communications.  I hesitate only because I'm more used to thinking about 
> these things in terms of message-passing protocols, but that's no reason to 
> reject your request.  My only bit of bikeshedding is that they ought to be a 
> different class to the basic Semaphore to make it clear they have a different 
> scope.
> 
> Is it worth broadening out the discussion to other sorts of named objects?  
> Named Pipes particularly spring to my mind...
> 
> -- 
> Rhodri James *-* Kynesim Ltd
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/FGOSCCHMCL6W5REF7JARMLOI44D4ULQI/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/FGZ6E3JOF5ZEIDTX4OAXROFPA4SQHIJC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to