GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — asyncio.staggered.staggered_race can log NameError: cannot access free variable 'exceptions' where it is not associated with a value in enclosing scope · Issue #128479 · python/cpython

asyncio.staggered.staggered_race can log NameError: cannot access free variable 'exceptions' where it is not associated with a value in enclosing scope #128479

New issue
Copy link
New issue
Copy link
Closed
Closed
asyncio.staggered.staggered_race can log NameError: cannot access free variable 'exceptions' where it is not associated with a value in enclosing scope#128479
Copy link
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@graingert
graingert
opened on Jan 4, 2025
Issue body actions

Bug report

Bug description:

https://github.com/Chia-Network/chia-blockchain/actions/runs/12586550910/job/35084132471#step:16:1813

______ test_long_reorg_nodes[ConsensusMode.HARD_FORK_2_0-2-500-100-True] _______
[gw1] darwin -- Python 3.12.8 /Users/runner/work/chia-blockchain/chia-blockchain/.venv/bin/python
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/staggered.py:104: in run_one_coro
    result = await coro_fn()
.venv/lib/python3.12/site-packages/aiohappyeyeballs/impl.py:166: in _connect_sock
    await loop.sock_connect(sock, address)
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/selector_events.py:651: in sock_connect
    return await fut
E   asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:
.venv/lib/python3.12/site-packages/anyio/pytest_plugin.py:160: in pytest_pyfunc_call
    runner.run_test(pyfuncitem.obj, testargs)
.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py:2316: in run_test
    self._raise_async_exceptions()
.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py:2220: in _raise_async_exceptions
    raise exceptions[0]
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/staggered.py:108: in run_one_coro
    exceptions[this_index] = e
E   NameError: cannot access free variable 'exceptions' where it is not associated with a value in enclosing scope

This occurs when created run_one_coro tasks outlive the staggered_race task

The fix is to repeatedly wait for a future that fires when all tasks are completed - and propagate any outside cancellation to the child tasks.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

  • gh-128479: fix asyncio staggered race leaking tasks, and logging unhandled exception.append exception #128475
  • [3.13] gh-128479: fix asyncio staggered race leaking tasks, and logging unhandled exception.append exception (GH-128475) #129227
  • [3.12] gh-128479: fix asyncio staggered race leaking tasks, and logging unhandled exception.append exception (GH-128475) #129228

Activity

  1. graingert
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jan 4, 2025
  2. picnixz
    added
    topic-asyncio
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Jan 4, 2025
  3. github-project-automation
    moved this to Todo in asyncioon Jan 4, 2025
  4. github-project-automation
    added this to asyncioon Jan 4, 2025
  5. graingert
    added
    3.12only security fixesonly security fixes
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    on Jan 4, 2025
  6. ambv
    added a commit that references this issue on Jan 23, 2025

    gh-128479: fix asyncio staggered race leaking tasks, and logging unha…

    ec91e1c
  7. miss-islington
    added 2 commits that reference this issue on Jan 23, 2025

    pythongh-128479: fix asyncio staggered race leaking tasks, and loggin…

    2234a53

    pythongh-128479: fix asyncio staggered race leaking tasks, and loggin…

    d5053a3
  8. ambv
    added 2 commits that reference this issue on Jan 23, 2025

    [3.13] gh-128479: fix asyncio staggered race leaking tasks, and loggi…

    75ec6ca

    [3.12] gh-128479: fix asyncio staggered race leaking tasks, and loggi…

    e94939c
  9. graingert
    closed this as completedon Jan 24, 2025
  10. github-project-automation
    moved this from Todo to Done in asyncioon Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • asyncio
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.