10000 [pull] main from python:main by pull[bot] · Pull Request #53 · webfutureiorepo/cpython · GitHub
[go: up one dir, main page]

Skip to content

[pull] main from python:main #53

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

Merged
merged 2 commits into from
Feb 28, 2025
Merged

[pull] main from python:main #53

merged 2 commits into from
Feb 28, 2025

Conversation

pull[bot]
Copy link
@pull pull bot commented Feb 28, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

This pull request improves the performance of frame locals proxy lookups and adds a lock to prevent race conditions when creating iOS simulators.

Enhancements:

Documentation:

gaogaotiantian and others added 2 commits February 27, 2025 18:12
Add a lock to ensure that only one iOS testbed per user can start at a time, so
that the simulator discovery process doesn't collide between instances.
@pull pull bot added the ⤵️ pull label Feb 28, 2025
@pull pull bot merged commit 9211b3d into webfutureiorepo:main Feb 28, 2025
Copy link
sourcery-ai bot commented Feb 28, 2025

Reviewer's Guide by Sourcery

This pull request addresses a memory management issue in framelocalsproxy and prevents race conditions during iOS simulator creation. It also includes a news fragment documenting the fix.

Sequence diagram for acquiring and releasing the SimulatorLock

sequenceDiagram
  participant RT as RunTestbed
  participant SL as SimulatorLock
  participant OS as OS

  RT->>SL: SimulatorLock(timeout)
  RT->>SL: await acquire()
  activate SL
  SL->>OS: filename.touch(exist_ok=True)
  loop timeout times
    SL->>OS: os.open(filename, os.O_RDWR | os.O_TRUNC, 0o644)
    OS-->>SL: fd
    SL->>OS: fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    alt Lock acquired
      OS-->>SL: Success
      SL-->>RT: Return
    else Lock not acquired
      OS-->>SL: OSError
      SL->>OS: os.close(fd)
      SL->>SL: await asyncio.sleep(1)
    end
  end
  deactivate SL
  RT->>SL: release()
  activate SL
  SL->>OS: fcntl.flock(fd, fcntl.LOCK_UN)
  SL->>OS: os.close(fd)
  deactivate SL
Loading

Updated class diagram for SimulatorLock

classDiagram
  class SimulatorLock {
    -Path filename
    -int timeout
    -int fd
    +__init__(timeout: int)
    +acquire() : void
    +release() : void
  }
  note for SimulatorLock "This class provides a file-based lock to prevent race conditions during iOS simulator creation."
Loading

File-Level Changes

Change Details Files
Improved framelocalsproxy object by ensuring values retrieved from cells are properly referenced and managed, preventing potential memory issues.
  • Modified framelocalsproxy_getval to return a new reference instead of a borrowed reference.
  • Added framelocalsproxy_hasval to check if a value exists without returning it.
  • Modified framelocalsproxy_getkeyindex to accept an optional value_ptr to return the value with a new reference.
  • Updated framelocalsproxy_getitem to directly return the value obtained from framelocalsproxy_getkeyindex.
  • Updated framelocalsproxy_keys to use framelocalsproxy_hasval.
  • Added Py_DECREF to release value in framelocalsproxy_values and framelocalsproxy_items.
  • Updated framelocalsproxy_length to use framelocalsproxy_hasval.
  • Updated framelocalsproxy_contains to use framelocalsproxy_getkeyindex without value.
Objects/frameobject.c
Implemented a simulator lock to prevent race conditions when creating multiple iOS simulators concurrently.
  • Added a SimulatorLock class with acquire and release methods to manage the lock.
  • Modified run_testbed to acquire the simulator lock before starting tests and release it afterwards.
  • Modified log_stream_task to receive the lock and release it after finding a new device.
  • Added a timeout to the lock acquisition to prevent indefinite blocking.
  • Added print statements to indicate the status of the lock.
iOS/testbed/__main__.py
Added a news fragment to document the fix for issue python#129200.
  • Added a new file Misc/NEWS.d/next/Tests/2025-02-26-15-10-16.gh-issue-129200.XH4TeC.rst.
Misc/NEWS.d/next/Tests/2025-02-26-15-10-16.gh-issue-129200.XH4TeC.rst

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0