Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions internal/usecase/devices/wsman/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ func (g GoWSMANMessages) Worker() {
for {
select {
case request := <-requestQueue:
request()
time.Sleep(queueTickTime)
go request()

@sudhir-intc sudhir-intc Sep 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amarnath-ac : moving to the asynchronous approach for sure would overcome the issue you observed with one request slowing down all subsequent requests. At the same time this brings in two issues to take care of:

  1. This approach allows multiple connections towards each device and they can execute concurrently, they may access the shared data at the same time which in this case is the Connections. This requires careful synchronization (like using mutexes) to prevent data races, did you check on that. Please check on this
  2. This approach can spawn a large number of go routines, did you check on that too

I would suggest to come out with a balanced approach where you create a fixed number of worker threads pool . Instead of spawning a new goroutine for every single request, you pre-spawn a fixed number of long-lived "worker" goroutines. These workers all listen to the same job queue and also ensure that workers handling requests for the same device ensure there are no race conditions

case <-shutdownSignal:
return
}
Expand Down
Loading