Skip to content

Fix Global Variable Thread-Safety Issue #4

@ShadowMarty

Description

@ShadowMarty

Description

The application uses a global variable to_say that's modified across multiple endpoints. When multiple farmers call simultaneously, their responses get mixed up because all calls share the same global variable. This is a critical production bug.

Example of the Problem:

Farmer A calls: "Tell me about PM-KISAN"
Farmer B calls: "Weather forecast please"
Agent sets to_say = "PM-KISAN gives Rs. 6000..."
Agent sets to_say = "Today's weather is sunny..." (overwrites!)
Farmer A hears: "Today's weather is sunny..." ❌ (Wrong response!)

What needs to be done:

  • Remove the global to_say variable
  • Implement session-based conversation storage using Flask sessions
  • Store conversation state per Call SID (unique for each call)
  • Update both /voice and /handle-speech endpoints
  • Test with concurrent calls (simulate using multiple requests)

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions