Skip to content

Commit

Permalink
Make sure that lammps contexts are properly finalized
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz committed Aug 3, 2023
1 parent 70640aa commit 2dc3b8d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pysages/backends/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import importlib
import weakref
from functools import partial

import jax
Expand Down Expand Up @@ -247,5 +248,7 @@ def bind(sampling_context: SamplingContext, callback: Optional[Callable], **kwar
# Unfortunately, the default implementation of `lammps.__exit__` closes
# the lammps instance, so we need to overwrite it.
context.__exit__ = lambda *args: None
# Ensure that the lammps context is properly finalized.
weakref.finalize(context, context.finalize)

return sampler

0 comments on commit 2dc3b8d

Please sign in to comment.