Skip to content

Conversation

@jpivarski
Copy link
Member

This:

executor = ThreadPoolExecutor(max_workers=16)

for array in uproot.iterate(
    [
        "/home/jpivarski/Downloads/Run2012B_DoubleMuParked.root:Events",  # https://opendata.cern.ch/record/12365
        "/home/jpivarski/Downloads/Run2012C_DoubleMuParked.root:Events",  # https://opendata.cern.ch/record/12366
    ],
    decompression_executor=executor,
    interpretation_executor=executor,   #  <--- especially this one
    handler=uproot.MemmapSource,
    step_size="1 GB",
):
    print(array)

was causing this:

  File "/home/jpivarski/storage/data/python-3.13-uproot/uproot/interpretation/numerical.py", line 108, in final_array
    basket_array = basket_arrays[basket_num]
                   ~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 290

in Python 3.13 with free-threading. But this PR fixes it.

Amusingly, it introduces a global lock. But it's a global lock on basket_array dicts, not all objects everywhere.

I've been monitoring the performance and this is even better than ignoring the problem (i.e. don't update the output array—output random bytes—in the rare cases in which the key is missing). This PR is faster and preserves correctness.

jpivarski added a commit to jpivarski-talks/2024-10-23-chep2024-gil-free-uproot that referenced this pull request Oct 3, 2024
@jpivarski jpivarski merged commit a8f674e into main Oct 7, 2024
26 checks passed
@jpivarski jpivarski deleted the jpivarski/concurrency-issue-in-313t branch October 7, 2024 14:25
pfackeldey pushed a commit to pfackeldey/uproot4 that referenced this pull request Jan 27, 2025
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.

2 participants