-
Notifications
You must be signed in to change notification settings - Fork 5
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
sals.process cleanup/refactor #555
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Matching google python docstring style - Adding missing info for cwd arg
- Removing Redundant type check - Updating the docstring, matching google style
- Update docstring to match google style - simplify the code
- Fixing issue #557. - Adding optional args timeout, sure_kill. - dealing with edge cases and ensure proper error handling. - updating the docstring.
- Adding new optional args limit, _alt_source - Changing the default_predicate operator to equality instead of contain - check against the exe and command basename not the whole command path - updating and restyling the docstring
- Restyling the docstring to match google style - Catching psutil.AccessDenied error
- using new get_pids `limit` option - removing redundant code and simplify the code - Restyling the docstring to match google style
- Making use of check_running() - Adding proper error handling - remove some make-no-sense code - use psutil.Popen to execute the cmd for a better control of the executed subprocess - Updating and restyling docstring
- Making use of check_running() - Adding proper error handling - remove some make-no-sense code - use psutil.Popen to execute the cmd for a better control of the executed subprocess - Updating and restyling docstring
- Adding proper error handler - Use psutil.Popen for better control of the executed subprocess - Updating the docstring and restyling it to match google style
- making use of get_pids() `limit` new option to make the function faster - Updating the docstring
- making use of kill_process_by_name() due to the similarities. - Updating the docstring
- Adding new optional args 'timeout' and 'sure_kill' - Making use of kill() 'timeout' and 'sure_kill' - Restyling the docstring
- getting rid of `ps` shell command replacing it with psutil - updating the docstring
- Making use of nettools sal - Adding support for ports bound to IPv6 localhost address using a new optional arg `ipv6` - Updating the docstring
- Adding proper error handling - Now it yields psutil.Process instead of retuning the pid(s) list for faster reusing between module functions and for consistency sake. - Updating the docstring
- Adding proper error handling - Now it Yielding the processes - Updating the docstring
- Making use of kill() `sure_kil` new option - Updating the docstring
- Adding proper error handling - Updating the docstring
- renaming args to more readable names. - Updating the docstring.
- Re-implementing the function to be more generic - Adding new args `ipv6`, `udp` - fix issue # 561 - Updating the docstring
- Adding optional args and supporting for `ipv6` and `udp` - Making use of get_pid_by_port() new args `ipv6` and `udp`
- Making use of get_process_by_port() and its new args - Making use of kill() new args `timeout` and `sure_kill`
abom
suggested changes
Feb 8, 2021
abom
approved these changes
Mar 7, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
sals.process cleanup/refactor
Changes
ps
shell command completely, and depend on psutil instead.Related Issues
closes #467
#541
closes #557
closes #561
Decisions Needed:
Suggested changes below are not included in this PR for compatibility reasons with any old code.
but it may be considered, discussed, and make decisions about:
1:
kill()
,check_start()
andcheck_stop()
functions returnTrue
when succeded. raise an exception otherwise.js-ng/jumpscale/sals/process/__init__.py
Line 102 in e610686
js-ng/jumpscale/sals/process/__init__.py
Line 271 in e610686
js-ng/jumpscale/sals/process/__init__.py
Line 313 in e610686
True
is redundant and not needed, it actually never returnFalse
. in case of the operation failed we raise an exception.Decision: the function should return None and the calling code should call the function inside try .. except, and never check for the output.
Update: Solved, after discussion with @abom. now, these functions return None.
2:
kill_all()
function default signal isSIGKILL
and inconsistent withkill()
function that haveSIGTERM
as a default signal also it almost have same functionality askill_process_by_name()
function.js-ng/jumpscale/sals/process/__init__.py
Line 167 in e610686
Decision:
kill_all()
default signal should be re-considered also the function itself should be deprecated and removed in favor ofkill_process_by_name()
because they are almost the same.Update: Solved, after discussion with @abom. now, this function deprecated and removed in favor of
kill_process_by_name()
3: the module functions divided between functions that return the processes as a list[int] represents the processes ID(s) (due to it was initially parsing the PIDs from the
ps
shell command output), and functions that return the processes as psutil.Process objects. passing PIDs is not reliable in case the process is gone and its PID reused by another process, also this will affect the performance when we initiate the psutil.Process objects repeatedly from pids between function calls.Decision: as we now depend completely on psutil in this module, all functions should return psutil.Porcess objects instead of PIDs: list[int], another alternative, the affected functions - specially get_pids() - could take a parameter to decide whether it should return processes IDs or the Processes objects.
4:
is_port_listening()
function is irrelevant in the process sal. it is already implemented in the nettools sal and should not re-implemented here.js-ng/jumpscale/sals/process/__init__.py
Line 578 in e610686
Decision: the function should be deprecated and removed in favor of
tcp_connection_test()
from the nettools sal.Checklist