indeedeng / indeedeng/iwf-python-sdk

publish_to_internal_channel is not threadsafe

Open
#115 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
6
Forks
3
PR merge metrics
No merged PRs in 30d

Description

https://github.com/indeedeng/iwf-python-sdk/blob/a13c309d58bb553a3ee27c85899f7f25c500d877/iwf/communication.py#L51

Here's part of the publish_to_internal_channel func :

def publish_to_internal_channel(self, channel_name: str, value: Any = None):     
    ...   
    vals = self._to_publish_internal_channel.get(channel_name)
    if vals is None:
        vals = []
    vals.append(self._object_encoder.encode(value))
    self._to_publish_internal_channel[channel_name] = vals

When multiple threads hitting this function, it could have a race condition where
Thread A gets vals = [1,2,3]
Thread B gets vals = [1,2,3]
Thread A updates it to be [1,2,3,4]
Thread B updates it to be [1,2,3,5]
Here we lost 4 permanently

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in iwf/communication.py at publish_to_internal_channel and review how _to_publish_internal_channel is read and updated. Add coverage for concurrent publishes, then verify that no values are lost when multiple threads publish to the same channel.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.