- Make sure you are in the root directory for the project.
- Run
pip install -r requirements.txt
- Run the application via the command
python run_sensor.py
- Run tests via the command
pytest
- This code was created with Python 3.8
- The application can be run in online or offline mode automatically.
- You can test this functionality by turning off your wifi, starting the application, viewing the output for several seconds, and then turning your wifi back on.
- While in offline mode, all states are stored in an in-memory queue (
DEAD_LETTER_QUEUE
) as well as on disk in case the system is shut down unexpectedly. - The application will automatically attempt to load the
dead_letter_queue.pkl
file into memory if it exists in the app root directory. - The use of aiohttp/asyncio is only beneficial while posting the dead letter queue to the API, since more than one request can be executed at the same time. Asyncio/aiohttp doesn't provide much performance gain for single requests.
- Append to
dead_letter_queue.pkl
file instead of re-creating it every time. - (minor) Use
try
andexcept
instead of if statements in the file loading functions. - Combine the POST of the queue with the POST of the current state so we have one POST, not two.
- Add test for simulating internet connection returning while the application is running.