Skip to content

Commit 69d929d

Browse files
committed
Add a missing interface
This was mentioned in the documentation but not actually implemented.
1 parent 9646ce0 commit 69d929d

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

astrometry/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,13 @@ def __exit__(
227227
value: typing.Optional[BaseException],
228228
traceback: typing.Optional[types.TracebackType],
229229
) -> bool:
230+
self.close()
231+
return False
232+
233+
def close(self):
230234
if self.inner is not None:
231235
self.inner.close()
232236
self.inner = None
233-
return False
234237

235238
def solve(
236239
self,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = [
88
]
99
requires-python = ">=3.9"
1010
dependencies = ["requests>=1.26"]
11-
version = "4.2.0"
11+
version = "4.2.1"
1212

1313
[project.urls]
1414
homepage = "https://github.com/neuromorphicsystems/astrometry/"

tests/test_memory.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def size_to_string(size: int) -> str:
6363
)
6464
assert solution.has_match()
6565
del solution
66-
memory_sample = process.memory_full_info().uss
67-
memory_samples[index] = memory_sample
68-
print(
69-
f"(repeated solver allocation with context manager) solve {index + 1} / {SOLVES}, memory usage: {size_to_string(memory_sample)}"
70-
)
66+
memory_sample = process.memory_full_info().uss
67+
memory_samples[index] = memory_sample
68+
print(
69+
f"(repeated solver allocation with context manager) solve {index + 1} / {SOLVES}, memory usage: {size_to_string(memory_sample)}"
70+
)
7171
deltas = numpy.diff(memory_samples)
7272
repeated_solver_allocation_with_context_manager_leak = (
7373
size_to_string(int(numpy.min(deltas[deltas >= 0]))),
@@ -91,6 +91,7 @@ def size_to_string(size: int) -> str:
9191
solution_parameters=astrometry.SolutionParameters(),
9292
)
9393
assert solution.has_match()
94+
solver.close()
9495
del solution
9596
del solver
9697
memory_sample = process.memory_full_info().uss
@@ -157,6 +158,7 @@ def size_to_string(size: int) -> str:
157158
),
158159
)
159160
del solution
161+
del stars
160162
memory_sample = process.memory_full_info().uss
161163
memory_samples[index] = memory_sample
162164
print(

0 commit comments

Comments
 (0)