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 Felipe A. Hernandez
Recipients Felipe A. Hernandez, davin, giampaolo.rodola, pitrou
Date 2020-07-09.20:10:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1594325420.21.0.0134943468042.issue35919@roundup.psfhosted.org>
In-reply-to
Content
import traceback
import multiprocessing.managers


class MyManager(multiprocessing.managers.SyncManager):
    pass

class DictList(multiprocessing.managers.BaseProxy):
    _method_to_typeid_ = {'__getitem__': 'dict'}

    def __getitem__(self, key):
        return self._callmethod('__getitem__', (key,))

MyManager.register('DictList', None, DictList)

with MyManager() as manager:

    nested = manager.DictList([{'hello': 'world'}])
    print(nested[0]['hello'])  # world

    proxy = manager.list([nested])
    try:
        print(proxy[0][0]['hello'])
    except AttributeError:
        traceback.print_exc()
        print("""
        Bug: AttributeError: ProxyBase._callmethod is None
        --------------------------------------------------

        This error is raised because proxies returned as #RETURN messages
        have no manager reference, which is required to resolve typeids
        (using BaseManager._registry).

        Only proxies returned as #PROXY messages will be fully functional.

        This is an undocumented current implementation limitation.

        Fix (proposal)
        --------------

        Include the manager class (not the instance) as part of the proxy
        serialization in BaseProxy.__reduce__, as BaseManager._registry is
        a class variable.

        Note: #PROXY message protocol can be also replaced by regular proxy
              serialization after this fix, resulting on simpler codebase.
        """)
History
Date User Action Args
2020-07-09 20:10:20Felipe A. Hernandezsetrecipients: + Felipe A. Hernandez, pitrou, giampaolo.rodola, davin
2020-07-09 20:10:20Felipe A. Hernandezsetmessageid: <1594325420.21.0.0134943468042.issue35919@roundup.psfhosted.org>
2020-07-09 20:10:20Felipe A. Hernandezlinkissue35919 messages
2020-07-09 20:10:20Felipe A. Hernandezcreate