Skip to content

[Ruby] ApiClient is not threadsafe when downloading files #16796

@dawson-conway

Description

@dawson-conway
Description

By default, the ruby client uses one ApiClient across all threads. This would be fine, but when downloading files, the ApiClient stores the tempfile reference in an instance variable. This leads to a race condition if two threads are making a call to an endpoint that downloads files at the same time, both calls may return the same file. So

Steps to reproduce

In two parallel threads, use the same Api Client to hit endpoints that download different files. It's a race condition, so it won't happen every time.

Suggest a fix/enhancement

Either the ApiClient.default() needs to return a thread-specific API client, or the tempfile needs to be stored in a thread-safe way (either a thread variable or local variable)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions