Multithreaded Data Logger

Medium Python Concurrency
Solve this problem

Implement a multithreaded Python logger that reads sensor data in one thread and logs it to a file in another thread using a queue. Synchronization and graceful shutdown are required.

Constraints

  • Use threading + queue.Queue.
  • Reader thread generates or reads data.
  • Logger thread writes to log.txt.
  • Stop on sentinel None.
  • Use join() for clean exit.
Starter codePython
1import threading, queue2# TODO