Author josh.r
Recipients georg.brandl, jcea, josh.r, kevincox
Date 2014-03-26.03:58:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
And for this particular case, even if the resource allocators don't support the context manager protocol, contextlib.closing can do the job:

    from contextlib import closing

    with closing(allocateresource1()) as resource1, closing(allocateresource2()) as resource2:

If it's not a simple as calling close, you can write your own simple manager wrapper that calls some other cleanup function use @contextlib.contextmanager.
Date User Action Args
2014-03-26 03:58:27josh.rsetrecipients: + josh.r, georg.brandl, jcea, kevincox
2014-03-26 03:58:27josh.rsetmessageid: <>
2014-03-26 03:58:27josh.rlinkissue21067 messages
2014-03-26 03:58:27josh.rcreate