Skip to content

Commit

Permalink
Close dummy samplers
Browse files Browse the repository at this point in the history
This fixes some ResourceWarnings.
  • Loading branch information
bmerry committed Apr 8, 2022
1 parent 784af0e commit 23e45c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/aiokatcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,12 @@ async def request_sensor_sampling(
# (so that the whole request is atomic).
for s in sensors:
try:
sensor.SensorSampler.factory(s, _dummy_observer, self.loop, strategy, *args)
sampler = sensor.SensorSampler.factory(
s, _dummy_observer, self.loop, strategy, *args)
except (TypeError, ValueError) as error:
raise FailReply(str(error)) from error
if sampler is not None:
sampler.close()
# Now create them for real
for s in sensors:
try:
Expand Down

0 comments on commit 23e45c0

Please sign in to comment.