-
Notifications
You must be signed in to change notification settings - Fork 467
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
Library is not thread safe #441
Comments
Good catch! FWIW the exception message is |
This particular test detects only one concurrency problem, so I cannot be sure there is none else. Still, this one is pretty clear.
Actually, I don't understand why this var is needed as it's used only once, right after its setting (though in a separate private method), and cleared after that. It's also not documented as a public attribute. The git history shows a lot of changes to the handling of this var but the current code seems strange to me. I've also noticed there is a lock in pytz acquired inside |
Another error possibly caused by thread non-safety:
The app was running in Flask in uwsgi with 8 threads. |
Possibly we could change |
Related to #276 |
Is this going to get fixed? |
There are other concurrency issues when multi-threading and having some invalid datetime strings. This causes
Expected output (which you can get if you thread lock the call):
Error output:
|
not yet, just replace
|
@nex2hex I tried using the custom function, but had the same issues as before ( |
To expand on the above reports, the concurrency issues don't just cause exceptions, they cause wrong results: In [1]: import dateparser
In [2]: from concurrent.futures.thread import ThreadPoolExecutor
In [3]: executor = ThreadPoolExecutor(64)
In [4]: def f():
...: # Adding some "French" causes dateparser to use Y-D-M order,
...: # even though the timestamp is in ISO format.
...: dateparser.parse('le 2021-02-05T05:47:15+00:00')
...: # This one should get parsed correctly.
...: return dateparser.parse('2021-02-05T05:47:15+00:00')
...:
In [5]: {future.result() for future in [executor.submit(f) for _ in range(100)]}
Out[5]:
{datetime.datetime(2021, 2, 5, 5, 47, 15, tzinfo=<StaticTzInfo 'UTC\+00:00'>),
datetime.datetime(2021, 5, 2, 5, 47, 15, tzinfo=<StaticTzInfo 'UTC\+00:00'>)}
In [6]: dateparser.__version__
Out[6]: '1.0.0' Looks like this behavior is already being fixed and verified by |
Info:
Code to reproduce error:
Error:
The text was updated successfully, but these errors were encountered: