[CRIU] [PATCH] [RFC] p.haul: close socket to the CRIU service if smth failed

Andrew Vagin avagin at parallels.com
Tue Mar 25 01:12:51 PDT 2014


On Tue, Mar 25, 2014 at 02:57:31AM +0400, Pavel Emelyanov wrote:
> On 03/24/2014 05:26 PM, Andrey Vagin wrote:
> > This patch implements __exit__ and __enter__ methods for the
> > criu_conn class and uses the "with" statement to access objects
> > of this class.
> > 
> > """
> > When the “with” statement is executed, Python evaluates the expression,
> > calls the __enter__ method on the resulting value (which is called a
> > “context guard”), and assigns whatever __enter__ returns to the variable
> > given by as. Python will then execute the code body, and no matter what
> > happens in that code, call the guard object’s __exit__ method.
> > """
> 
> Isn't it easier just to call cc.close() at the end? Just wondering.

I want to handle exception too. For some reason garbage collector
doesn't collect this object if an exception has been raised.


More information about the CRIU mailing list