Skip to content

Commit

Permalink
Join the threads.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtgee committed May 24, 2024
1 parent 3a62f73 commit 39e0e3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/panoptes/pocs/utils/service/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def record_readings():
power_thread.start()

yield
power_board.logger.info('Shutting down power board')
power_board.logger.info('Shutting down power board, please wait.')
power_thread.join()


app = FastAPI(lifespan=lifespan)
Expand Down
5 changes: 4 additions & 1 deletion src/panoptes/pocs/utils/service/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ async def lifespan(app: FastAPI):
with suppress(FileNotFoundError):
ioptron_port = os.readlink('/dev/ioptron')

weather_thread: Thread = None

# Try to connect to the weather station.
for port in ports:
if 'ttyUSB' not in port:
Expand Down Expand Up @@ -68,7 +70,8 @@ def record_readings():
raise RuntimeError('Could not connect to weather station.')

yield
weather_station.logger.info('Shutting down weather station')
weather_station.logger.info('Shutting down weather station, please wait')
weather_thread.join()


app = FastAPI(lifespan=lifespan)
Expand Down

0 comments on commit 39e0e3f

Please sign in to comment.