Content-Length: 228374 | pFad | http://github.com/pyparsing/pyparsing/issues/604

73 Concurrency issue on Cache when packrat is enabled. · Issue #604 · pyparsing/pyparsing · GitHub
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 issue on Cache when packrat is enabled. #604

Open
CarlosDescalziIM opened this issue Apr 1, 2025 · 2 comments
Open

Concurrency issue on Cache when packrat is enabled. #604

CarlosDescalziIM opened this issue Apr 1, 2025 · 2 comments
Assignees

Comments

@CarlosDescalziIM
Copy link

Cache operations get and set are used inside a reentrant lock, but cache clear is called from parse_string outside that reentrant lock.

FifoCache set operation does this:

        def set_(_, key, value):
            cache[key] = value
            while len(cache) > size:
                # pop oldest element in cache by getting the first key
                cache_pop(next(iter(cache)))

That cache_pop(next(iter(cache)) is not thread safe.

Creating a bunch of threads parsing expressions in loop eventually raise a RuntimeError dictionary changed size during iteration
To reproduce it easier put another thread to call ParserElement.reset_cache() in loop

@CarlosDescalziIM CarlosDescalziIM changed the title Concurrency issue on Cache when packrat issue enabled. Concurrency issue on Cache when packrat is enabled. Apr 1, 2025
@ptmcg ptmcg self-assigned this Apr 2, 2025
@ptmcg
Copy link
Member

ptmcg commented Apr 2, 2025

Thanks for posting, and describing the process for reproducing the issue. I'll give it a look in the next day or so.

@ptmcg
Copy link
Member

ptmcg commented Apr 5, 2025

I was unable to reproduce this issue, but have added the lock synchronization in the necessary places. Will go out in the next release.

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

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/pyparsing/pyparsing/issues/604

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy