[New-bugs-announce] [issue20626] Manager documentation unclear about lists and thread safeness
report at bugs.python.org
Fri Feb 14 15:56:06 CET 2014
New submission from Irvin Probst:
In the the Manager's lists documentation one can read:
Create a shared list object and return a proxy for it.
IMHO it is really unclear whether these lists have something more than traditionnal lists or not.
When you have a look at managers.py it is quite obvious, unless I'm completely wrong, that the underlying shared object is a standard list with a basic proxy to expose all the "underscore underscore stuff".
BaseListProxy = MakeProxyType('BaseListProxy', (
'__add__', '__contains__', '__delitem__', '__getitem__', '__len__',
'__mul__', '__reversed__', '__rmul__', '__setitem__',
'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
'reverse', 'sort', '__imul__'
def __iadd__(self, value):
def __imul__(self, value):
[snip a couple of lines]
SyncManager.register('list', list, ListProxy)
That's really confusing because, unless reading managers.py, you have the feeling that the manager's lists() are somehow different than standard lists.
The other problem is that, if you don't know what level of thread-safeness the GIL guarantees on the lists in the manager's server thread, you have the feeling that the safeness comes from some obscure Manager's black magic managing concurrent access for you.
May I suggest to add in the documentation:
Create a shared list (add here a link to http://docs.python.org/3.3/library/stdtypes.html#list) object and return a proxy for it.
Clearly state somewhere in the manager's documentation that it's the developper's job to ensure that the proxied methods are thread safe. Write it in bold and red please :-)
Perhaps add an example with a custom object like the code I attached to this report.
Thanks for your time.
title: Manager documentation unclear about lists and thread safeness
Added file: http://bugs.python.org/file34080/example.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce