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

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

Closed
andrek-data-axle opened this issue Oct 16, 2020 · 6 comments

Comments

@andrek-data-axle
Copy link

andrek-data-axle commented Oct 16, 2020

I am assuming its a concurrency issue because the only way I can get it to fail is running multiple calls to dateparser.parse('14 days ago UTC') on separate threads.

  File "/var/app/current/credit/users/services/profile.py", line 67, in add_profile
    date_viewed__gt=dateparser.parse('14 days ago UTC')
  File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/dateparser/conf.py", line 85, in wrapper
    return f(*args, **kwargs)
  File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/dateparser/__init__.py", line 53, in parse
    data = parser.get_date_data(date_string, date_formats)
  File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/dateparser/date.py", line 418, in get_date_data
    locale, date_string, date_formats, settings=self._settings)
  File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/dateparser/date.py", line 194, in parse
    return instance._parse()
  File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/dateparser/date.py", line 198, in _parse
    date_obj = self._parsers[parser_name]()
  File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/dateparser/date.py", line 212, in _try_freshness_parser
    return freshness_date_parser.get_date_data(self._get_translated_date(), self._settings)
  File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/dateparser/freshness_date_parser.py", line 149, in get_date_data
    date, period = self.parse(date_string, settings)
  File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/dateparser/freshness_date_parser.py", line 94, in parse
    date, period = self._parse_date(date_string, settings.PREFER_DATES_FROM)
  File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/dateparser/freshness_date_parser.py", line 134, in _parse_date
    date = self.now - td
TypeError: unsupported operand type(s) for -: 'NoneType' and 'relativedelta'
abkonsta pushed a commit to abkonsta/dateparser that referenced this issue Oct 16, 2020
@abkonsta
Copy link

I monkey patched in my project and was able to stress-test it with no more concurrency issues in freshness_date_parser
Pull request submitted.

@Gallaecio
Copy link
Member

@abkonsta
Copy link

abkonsta commented Oct 30, 2020 via email

@Gallaecio
Copy link
Member

Shall we close this and keep just #441 to track work to make it thread-safe?

@abkonsta
Copy link

abkonsta commented Nov 4, 2020 via email

@noviluni
Copy link
Collaborator

Closing as duplicate of #441. I hope this PR: #834 would fix this once and for all :)

Thanks for providing feedback!

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 a pull request may close this issue.

4 participants