Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching to using an instance of the SmarterCSV::Reader class #279

Merged
merged 17 commits into from
Jul 8, 2024

Conversation

tilo
Copy link
Owner

@tilo tilo commented Jul 3, 2024

this PR fixes issues around SmarterCSV being thread-safe, e.g. in response to #277

This PR moves away from using a module method, e.g. SmarterCSV.process,
and instead using an instance reader = SmarterCSV::Reader that contains state, and calling reader.process on it.

For backwards compatibility there is a shim that allows existing code to use SmarterCSV.process for the simplest cases, but it no longer gives access to the internal state, e.g. headers, raw_headers, ...

Please update your code to the new calling mechanism.

@tilo tilo mentioned this pull request Jul 3, 2024
Copy link

codecov bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (a906f19) to head (f6270e1).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #279   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        12    +1     
  Lines          380       435   +55     
=========================================
+ Hits           380       435   +55     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tilo tilo changed the title Move to using an instance of the SmarterCSV::Reader class Switching to using an instance of the SmarterCSV::Reader class Jul 4, 2024
Copy link
Contributor

@jpcamara jpcamara left a comment

Choose a reason for hiding this comment

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

The overall approach looks great. Definitely like just making a distinct new Reader class and wrapping that. I've only been able to skim things so far, but seems like it would fix the threading issues!

@tilo
Copy link
Owner Author

tilo commented Jul 6, 2024

The overall approach looks great. Definitely like just making a distinct new Reader class and wrapping that. I've only been able to skim things so far, but seems like it would fix the threading issues!

I ran your test for a long time, and no thread safety issues.

@tilo
Copy link
Owner Author

tilo commented Jul 8, 2024

@jpcamara @contentfree I'm releasing this as 1.12.0.pre1

@tilo tilo merged commit a89ca11 into main Jul 8, 2024
3 of 27 checks passed
@chaadow
Copy link

chaadow commented Jul 8, 2024

hi @tilo thanks for merging this! Is it possible to update the Changelog to make it clear that this gem has become thread safe thanks!

@tilo
Copy link
Owner Author

tilo commented Jul 8, 2024

hi @tilo thanks for merging this! Is it possible to update the Changelog to make it clear that this gem has become thread safe thanks!

thanks for pointing that out! done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants