Skip to content

Remove self.now from freshness_date_parser in favor of a local variable (#813) - #814

Closed
abkonsta wants to merge 1 commit into
scrapinghub:masterfrom
abkonsta:master
Closed

abkonsta wants to merge 1 commit into
scrapinghub:masterfrom
abkonsta:master

Conversation

@abkonsta

@abkonsta abkonsta commented Oct 16, 2020 •

Copy link
Copy Markdown

In web server environment, since freshness_date_parser is a shared instance, it looks like self.now was set to None by some threads while still being used by others.

This change removes self.none from FreshnessDateDataParser and instead introduces a local variable insude FreshnessDateDataParser.parse().

I could've also just removed the statement at the end of pase() setting self.now to None, but I feel that this way is cleaner.

Thanks!

Fixes #813

@codecov

codecov Bot commented Oct 16, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #814 into master will decrease coverage by 0.00%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #814      +/-   ##
==========================================
- Coverage   98.37%   98.36%   -0.01%     
==========================================
  Files         231      231              
  Lines        2518     2515       -3     
==========================================
- Hits         2477     2474       -3     
  Misses         41       41              
Impacted Files Coverage Δ
dateparser/freshness_date_parser.py 98.93% <93.33%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f81cf3...21ed5ce. Read the comment docs.

@alex-triphonov

Copy link
Copy Markdown

Thanks, would be nice to have this merge it to make dateparser thread safe!

@noviluni noviluni added this to the 1.1.0 milestone Oct 26, 2020
@noviluni

Copy link
Copy Markdown
Contributor

Hi @abkonsta, thank you for submitting this PR! 😄

Could you...

  1. explain how did you performed the stress tests you mention in Concurrency issues resulting in TypeError: unsupported operand type(s) for -: 'NoneType' and 'relativedelta' #813 (comment)
  2. Rename the local_now variable to just now.
  3. fix the conflicts
    ?

Thanks in advance!

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.

Concurrency issues resulting in TypeError: unsupported operand type(s) for -: 'NoneType' and 'relativedelta'

3 participants