indeedeng / indeedeng/iwf-python-sdk
publish_to_internal_channel is not threadsafe
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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