#1238 patching leaky context manager