Skip to content

Commit

Permalink
Merge pull request #274 from cta-observatory/fix_still_running_subpro…
Browse files Browse the repository at this point in the history
…cess

Fix ResourceWarnings when using the zcat implementation
  • Loading branch information
maxnoe authored Mar 23, 2024
2 parents 87d6314 + 9a76a8b commit 12d82fd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
15 changes: 12 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ exclude = ["eventio._dev_version"]
[tool.setuptools_scm]
version_file = "src/eventio/_version.py"


[tool.pytest]
addopts = "-v --durations=10"
[tool.pytest.ini_options]
minversion = "7"
testpaths = ["tests"]
log_cli_level = "INFO"
xfail_strict = true
# print summary of failed tests, force errors if settings are misspelled
addopts = ["-ra", "--strict-config", "--strict-markers", "-v", "--durations=10"]
filterwarnings = [
"error",
"ignore:File seems to be truncated:UserWarning",
"ignore:Version unknown:UserWarning", # pycorsikaio
]
11 changes: 9 additions & 2 deletions src/eventio/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def seek(self, offset, whence=0):
return self.pos

def close(self):
return self.pipe.close()
pass

def tell(self):
return self.pos
Expand Down Expand Up @@ -144,9 +144,16 @@ def __exit__(self, exc_type, exc_value, traceback):
self.close()

def close(self):
self._filehandle.close()
if self.read_process is not None:
self.read_process.terminate()
self.read_process.stdout.close()
self.read_process.stderr.close()
self.read_process.wait(timeout=1)

self._filehandle.close()

def __del__(self):
self.close()


def check_size_or_raise(data, expected_length, zero_ok=True):
Expand Down
1 change: 0 additions & 1 deletion tests/simtel/test_compare_hessio.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
from pkg_resources import resource_filename
import numpy as np
pyhessio = pytest.importorskip("pyhessio")

Expand Down
9 changes: 4 additions & 5 deletions tests/test_open_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def test_types_gzip():
def test_types_zcat():
from eventio.base import PipeWrapper
testfile = 'tests/resources/one_shower.dat.gz'
f = eventio.EventIOFile(testfile)

assert isinstance(f._filehandle, PipeWrapper)
types = [o.header.type for o in f]
assert types == [1200, 1212, 1201, 1202, 1203, 1204, 1209, 1210]
with eventio.EventIOFile(testfile) as f:
assert isinstance(f._filehandle, PipeWrapper)
types = [o.header.type for o in f]
assert types == [1200, 1212, 1201, 1202, 1203, 1204, 1209, 1210]

0 comments on commit 12d82fd

Please sign in to comment.