[PATCH] test-bundle2-format.t: force gc so a GeneratorExit will be thrown

Gregory Szorc gregory.szorc at gmail.com
Sat Jan 2 13:54:23 CST 2016


On Fri, Jan 1, 2016 at 10:51 AM, Bryan O'Sullivan <bos at serpentine.com>
wrote:

>
> On Tue, Dec 29, 2015 at 2:55 PM, Augie Fackler <raf at durin42.com> wrote:
>
>> I'm a little weirded out by this fix, because it worries me that it is
>> going to choke us in weird ways in production. Can you allay that fear at
>> all?
>>
>
> I don't think it's really the right fix myself – we need something more
> deterministic than relying on the refcount dropping to zero or the gc
> running.
>
> Along those lines, do we have an opinion on the use of "with" vs
> "try/finally" now that we're in 2.6 land? There seem to be no uses of
> "with" yet in the codebase, but it would be useful to standardise on one
> mechanism. The big advantage of "with" is that with a bit of hacking, we
> can collapse what would otherwise have to be nested try/finally blocks into
> one.
>

I prefer "with" over try..finally. One reason is that cleanup code is
*always* handled by the context manager itself rather than relying on the
caller to do the right thing (which is prone to bugs). "with" also
reinforces that there is something with a limited lifetime. With regular
functions or objects, you don't always know when you need to use "finally"
to clean up state. Again, this can lead to more bugs.

Context manager all of the things.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20160102/8c166c96/attachment.html>


More information about the Mercurial-devel mailing list