Python Threading example with exit handling and queue