Closed rsiera closed 7 years ago
Hi , This looks like its under development. Any particular reason why there has been no conversation over this ? Also, would like to help with the port
Stupid question: why would we want to support pg_view
on Mac OS? It's hard to test whether the support will continue to work for Linux developers like myself (no legal way of running Mac OS...) and nobody (?) is running production workloads on Mac OS (?).
I can see some reasons:
Hi, thanks for the pull request! I hope I will get to reviewing it at some point in the near future.
Hi,
I took a look at your changes and tried to run it on both Linux on OS X.
On Linux, I had to change the requirements to avoid asking for the very latest psycopg2.6.2, as a lot of systems ship with older version of psycopg2, as far as 2.4.5 is known to works normally with pg_view.
On OS X, I couldn't run it until I changed the code that calculates the diffs for PostgreSQL process:
def process_sort_key(process):
- return process.get('age', maxsize)
+ return process.get('age', maxsize) or maxsize
On a busy Linux system I observed pg_view crashing every minute or so with NoSuchProcess: psutil.NoSuchProcess no process found with pid 13105
I think this problem is not specific to Linux, since psutil is used for both platforms, I just don't have a busy OS X host to check :-) I think it tries to collect statistics for the process that is already gone and doesn't handle this exception gracefully. The original code handled such exceptions and continued working (look, for example, at _read_proc).
I like your restructuring of the code into multiple modes, although I think some smaller files (those, describing the constants, factories, exceptions) could be combined into a single one, something like "utils.py" or "misc.py".
Unfortunately, in the current state the code is impossible to review, as it's hard to tell the pieces of the code that were changed from those that were moved from pg_view.py into smaller files. I'd propose to split this pull request into several, perhaps, the one that does the code reshuffling without changing the actual code, another one that changes the code without introducing psutils and the third one that adds psuitils. What do you think?
I've also looked on it and tried to run on my home laptop where I have a python compiled without ipv6 support and it was failing because of that.
Besides problems with process_sort_key
and ipv6 there are come problems with python3 compatibility which are not that hard to fix.
I think it is already too late to split this pull request into multiple, because usually nobody likes to do the same job twice.
May be we should merge it into separate branch, apply all obvious fixes, do some further refactoring and when it would be mature enough merge it to master?
@CyberDem0n I think we could do this, but it would take much more time to review and get it in shape. @rsiera what do you think? Are you willing to submit this pull requests in chunks, so that we can review it quickly, or should we take it and treat like a black box, figuring out what has changed and how it works anew?
Although it would be more work for me, I totally agree with @alexeyklyukin. In current state it's very difficult to make a good code review, because this PR contains refactoring + adding psutils at once + it's quite big. Your approach with dividing it to 3 PR would be better. So I'll prepare following pull request:
I will ask you for code-review after every single step, and it should be much easier to review and to achieve working version with psutil support. Thanks for feedback and pointing out issues, I have tested new version on Mac OS + VM with Linux but didn't check these cases, I will take take a look at these issues during second step. I had to mix sth up when handling exceptions ;-)
Makes sense to me, thank you. This PR is closed.
Implementation of #60 - Support for OSX(and other platforms). Honestly I didn't expect so many changes, but in order to replace getting data from /proc file with psutil functions I had to do some refactor, write tests. Dividing this script to modules, separating some common logic to classes makes it much easier. Please review and inform me what do you think about that ? I use this script very often and have some ideas what could be useful and I would be willing to implement some new features. I hope that these changes and especially tests, made this code easier to maintain and improve.