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 davin
Recipients Cezary.Wagner, davin
Date 2015-02-24.17:20:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1424798455.15.0.481586469226.issue23510@psf.upfronthosting.co.za>
In-reply-to
Content
A much simpler example of code triggering the described issue:

    import multiprocessing.managers
    with multiprocessing.managers.SyncManager() as s:
        print "here"


Running the above code in 2.7.9 results in an exception with the traceback:

    Traceback (most recent call last):
      File "<stdin>", line 2, in <module>
      File "/home/somewhere/python/lib/python2.7/multiprocessing/managers.py", line 602, in __exit__
        self.shutdown()
    AttributeError: 'SyncManager' object has no attribute 'shutdown'



This is because the implementation of context manager functionality for multiprocessing.managers.BaseManager appears to have a bug.  The above snippet of code might as well have been written to use BaseManager instead of SyncManager and the resulting behavior would have been the same.

To be fair, nothing in the documentation appears to suggest that BaseManager or its subclasses can / should be used with the 'with' statement (as proper context managers).  But it is also natural to react to the existence of '__enter__' and '__exit__' and think to try using it with a 'with' statement.

Specifically in BaseManager, it looks like self.shutdown should have been set via __enter__'s call to start() yet inside __exit__ it's not resolving.

I believe we need:
1) A patch to fix the broken behavior;
2) a test to validate that it works and specifically exercise the use of BaseManager with a 'with' statement;
3) an update to the docs to advertise context manager capability in these classes.
History
Date User Action Args
2015-02-24 17:20:55davinsetrecipients: + davin, Cezary.Wagner
2015-02-24 17:20:55davinsetmessageid: <1424798455.15.0.481586469226.issue23510@psf.upfronthosting.co.za>
2015-02-24 17:20:55davinlinkissue23510 messages
2015-02-24 17:20:54davincreate