Skip to content

Fix exit method to use sys.exit for proper cleanup #842

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Aareon
Copy link
Contributor

@Aareon Aareon commented Jun 8, 2025

Summary

Changes the exit method in RNS.__init__.py to use sys.exit() instead of os._exit() to allow proper cleanup and exception handling.

Changes

  • Replace os._exit() with sys.exit() in the exit method
  • Keep panic method using os._exit() for immediate termination in unrecoverable scenarios

Rationale

The exit method should allow for proper cleanup (finally blocks, atexit handlers, buffer flushing) while the panic method should remain for immediate termination in catastrophic failures.

Resolves #822

Aareon added 2 commits June 8, 2025 18:28
Change RNS.__init__.py exit method from os._exit to sys.exit to allow
proper cleanup and exception handling. Keep panic method using os._exit
for immediate termination in unrecoverable scenarios.
Change `RNS.__init__.py` exit method from `os._exit` to `sys.exit` to allow proper cleanup and exception handling. Keep `panic` method using `os._exit` for immediate termination in unrecoverable scenarios.

Resolves markqvist#822
@Aareon
Copy link
Contributor Author

Aareon commented Jun 9, 2025

It looks like #730 also resolves #822, but this PR is more targeted. I would personally merge this to test this behavior before merging #730 to close the gap.

Aareon added 9 commits June 10, 2025 13:01
- Add .venv/ to ignore Python virtual environment directory
- Add __pycache__/ to ignore Python bytecode cache files
- Replace setup.py install with standards-based pyproject.toml configuration
- Add explicit Python 3.7-3.13 support in classifiers
- Maintain all existing console scripts and dependencies
- Use dynamic versioning from RNS._version.__version__
- Add project URLs and improved metadata
- Resolve setuptools deprecation warnings for 2025-Oct-31 deadline

This addresses the "setup.py install is deprecated" warnings and follows
PEP 518/621 standards for modern Python packaging.

Fixes: Multiple SetuptoolsDeprecationWarning messages
Resolve Pylance error where "Reticulum" is not defined on line 195.
The variable should be referenced as RNS.Reticulum since only the RNS
module is imported, not the Reticulum class directly.
Replace exec() call with direct string parsing to read version from
RNS/_version.py. This resolves the Pylance "reportUndefinedVariable"
error while maintaining single-source-of-truth for version management.

- Remove exec(open("RNS/_version.py").read()) pattern
- Add simple string parsing: f.read().split('=')[1].strip().strip('"')
- Eliminates scope issues with version variable access
Replace invalid list expression syntax `[Callable[[int], None]]` with proper type annotation `list[Callable[[int], None]]` on line 127 of Buffer.py to resolve Pylance reportInvalidTypeForm error.
Add type: ignore comment to suppress Pylance reportInvalidTypeForm error
when using NewType with Callable. The code is semantically correct but
Pylance/Pyright has known issues recognizing NewType variables as valid
type expressions in certain contexts.

This preserves the intended type safety of MessageCallbackType while
resolving the static analysis warning.
Add missing RNS.Reticulum.get_instance() calls in get_rssi(), get_snr(),
and get_q() methods to properly reference the Reticulum instance before
calling packet query methods. This resolves the "reticulum is not defined"
error on line 372 and follows the established pattern used elsewhere in
the codebase.
Replace invalid [MessageBase] list notation with proper typing.List[MessageBase]
syntax to resolve Pylance reportInvalidTypeForm error. The bracket notation
[T] is not valid for type expressions in Python - must use typing.List[T] or
list[T] (Python 3.9+) instead.
Replace `from RNS.Interfaces import *` with explicit imports to resolve
Pylance error "PipeInterface is not defined" on line 752. Added direct
imports for all interface modules including PipeInterface and
AX25KISSInterface to ensure proper module resolution and improve code
clarity. This approach eliminates ambiguity in module loading and makes
dependencies explicit.
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.

Use of os._exit() in RNS.exit() does not allow for proper cleanup
1 participant