Skip to content

[Question?] Potential Race Condition in Session Handling with Concurrent Requests #733

@megatron-quang-th-backend

Description

Issue

I am using the Shopify Python API to create products across multiple stores. My process involves activating a session for each store before making API requests. However, I am concerned about potential race conditions when handling concurrent requests.

Scenario

I activate a session for Store A and start creating a product using the GraphQL API.
While the above request is in progress, I activate a session for Store B and start creating a product for that store.

Question: Could the session for Store A be mistakenly used for the request intended for Store B due to a race condition in concurrent scenarios? In other words, is there a risk of one store's session being overridden or misapplied during concurrent requests?

Additional Context

I am aware that the activate_session method sets the session globally. My concern is whether concurrent operations might lead to session conflicts, where one thread might use the session intended for another.

If this is a known issue, are there recommended practices for managing sessions in a multi-threaded or concurrent environment to avoid such conflicts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions