Add `name` parameter to a `SharedMemoryManager.ShareableList` method
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 36k
- Merge medio
- 1g 9h
- PR unite (30g)
- 558
Descrizione
Feature or enhancement
I would like to pass a name for shared list from SharedMemoryManager but I apparently cannot do this.
with SharedMemoryManager() as smm:
my_shared_list = smm.ShareableList(sequence=range(10),name="special name")
pass
What I get:
my_shared_list = smm.ShareableList(sequence=range(10),name="special name")
TypeError: SharedMemoryManager.ShareableList() got an unexpected keyword argument 'name'
Possible solution
Just change method ShareableList in the bottom of this source file to following:
def ShareableList(self, sequence, name=None):
"""Returns a new ShareableList instance populated with the values
from the input sequence, to be tracked by the manager."""
with self._Client(self._address, authkey=self._authkey) as conn:
sl = shared_memory.ShareableList(sequence=sequence,name=name)
try:
dispatch(conn, None, 'track_segment', (sl.shm.name,))
except BaseException as e:
sl.shm.unlink()
raise e
return sl
I wonder
Why this feature is not implemented from the very beggining?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in Lib/multiprocessing/managers.py, nel metodo SharedMemoryManager.ShareableList vicino alla fine del file, quindi confrontalo con il parametro name di shared_memory.ShareableList. Il lavoro è completo quando il metodo del manager accetta e inoltra name, mantenendo il comportamento di tracciamento e pulizia.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- operating-systems
- Tipo di issue
- Funzionalità
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 60/100