pycuda icon indicating copy to clipboard operation
pycuda copied to clipboard

Implement `__enter__` and `__exit__` for CUDA context

Open riaqn opened this issue 2 years ago • 1 comments

People like me always forgot to pop context and cause errors. By implementing these two methods, the python will handle the context automatically. See https://book.pythontips.com/en/latest/context_managers.html This also helps when there is an exception.

riaqn avatar Nov 27 '21 13:11 riaqn

That sounds reasonable. I'd be happy to take a PR.

inducer avatar Mar 29 '22 23:03 inducer