Instead of using with syntax you can try manually using the context manager with __enter__() and __exit__(None, None, None)
with
__enter__()
__exit__(None, None, None)