Implement a Thread-Safe Pub-Sub Service

Quick Overview

This question evaluates concurrent programming and thread-safety skills within the Software Engineering Fundamentals domain, focusing on synchronization primitives, message delivery semantics, and coordination between publishers and subscribers at a practical application level.

Implement a Thread-Safe Pub-Sub Service

Company: Hot Agent Startup

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

Implement a simple server-side publish-subscribe system using Python's standard `threading` library. Requirements: - Multiple publisher threads may publish messages concurrently. - Multiple subscriber threads may subscribe to topics concurrently. - A subscriber can subscribe to and unsubscribe from a topic. - When a message is published to a topic, all currently subscribed subscribers should receive the message. - The implementation must avoid race conditions and deadlocks. - Use Python threading primitives such as `Lock`, `RLock`, `Condition`, `Event`, and thread-safe queues where appropriate. - Discuss delivery semantics, shutdown behavior, and how to avoid one slow subscriber blocking all publishers.

Overview: This question evaluates concurrent programming and thread-safety skills within the Software Engineering Fundamentals domain, focusing on synchronization primitives, message delivery semantics, and coordination between publishers and subscribers at a practical application level.

|Home/Software Engineering Fundamentals/Hot Agent Startup
H
Hot Agent Startup
Apr 3, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
1
0

Implement a simple server-side publish-subscribe system using Python's standard threading library.

Requirements:

  • Multiple publisher threads may publish messages concurrently.
  • Multiple subscriber threads may subscribe to topics concurrently.
  • A subscriber can subscribe to and unsubscribe from a topic.
  • When a message is published to a topic, all currently subscribed subscribers should receive the message.
  • The implementation must avoid race conditions and deadlocks.
  • Use Python threading primitives such as Lock , RLock , Condition , Event , and thread-safe queues where appropriate.
  • Discuss delivery semantics, shutdown behavior, and how to avoid one slow subscriber blocking all publishers.
Loading comments...