Skip to content

Rtop 73 create runtime manager from python side#8

Merged
thiagoralves merged 6 commits into
developmentfrom
RTOP-73-Create-runtime-manager-from-Python-side
Sep 24, 2025
Merged

Rtop 73 create runtime manager from python side#8
thiagoralves merged 6 commits into
developmentfrom
RTOP-73-Create-runtime-manager-from-Python-side

Conversation

@thiagoralves
Copy link
Copy Markdown
Contributor

This PR adds a RuntimeManager class that controls the runtime C core execution from the Python side. The user only needs to keep track of the main Python application. There is no need to keep track of the plc_main app anymore.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 23, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a RuntimeManager class to control the runtime C core execution from the Python side, simplifying runtime management by eliminating the need to track the plc_main app separately.

  • Replaces direct UnixClient and UnixLogServer usage with a unified RuntimeManager
  • Adds process monitoring and automatic restart capabilities
  • Consolidates runtime control methods (ping, start_plc, stop_plc) into the manager

Reviewed Changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated 4 comments.

File Description
webserver/runtimemanager.py New RuntimeManager class with process lifecycle management and monitoring
webserver/unixclient.py Removes PLC control methods (ping, start_plc, stop_plc) now handled by RuntimeManager
webserver/app.py Replaces direct client/server usage with RuntimeManager integration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread webserver/runtimemanager.py
Comment thread webserver/runtimemanager.py Outdated
Comment thread webserver/runtimemanager.py
Comment thread webserver/runtimemanager.py Outdated
Comment thread core/.DS_Store Outdated
Comment thread .DS_Store Outdated
Comment thread webserver/runtimemanager.py Outdated
Comment thread webserver/runtimemanager.py Outdated
Comment thread webserver/runtimemanager.py Outdated
Comment thread webserver/runtimemanager.py Outdated
Comment thread webserver/runtimemanager.py Outdated
Comment thread webserver/runtimemanager.py Outdated
Comment thread webserver/runtimemanager.py Outdated
Comment thread webserver/runtimemanager.py Outdated
@thiagoralves thiagoralves merged commit d2a99a3 into development Sep 24, 2025
@thiagoralves thiagoralves deleted the RTOP-73-Create-runtime-manager-from-Python-side branch September 24, 2025 16:41
thiagoralves added a commit that referenced this pull request Mar 5, 2026
- Fix #2: Guard buffer mutex release after crash with a volatile flag
  (holding_buffer_mutex) to avoid undefined behavior when unlocking a
  mutex not owned by the calling thread

- Fix #3: Reset plc_crash_signal to 0 at the start of plc_cycle_thread
  so stale values don't persist after successful recovery

- Fix #4: Add plc_force_error_state() function for the watchdog to
  transition to ERROR state through the mutex instead of writing
  plc_state directly. Remove extern PLCState from watchdog.c

- Fix #5: Skip watchdog heartbeat check when already in ERROR state
  to prevent repeated error log spam every 2 seconds. Move heartbeat
  reset to the non-RUNNING branch so it happens once on ERROR entry

- Fix #6: Add trailing newline to plc_state_manager.h

- Fix #8: Add threading.Lock to protect _crash_times and _safe_mode
  in RuntimeManager against concurrent access from the monitor and
  compilation threads

- Fix #9: Rename _should_enter_safe_mode to
  _record_crash_and_check_safe_mode to make the side effect explicit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

3 participants