I am running a multithreaded python(3.3) application which has been compiled using cx_freeze. I need to monitor the CPU usage, Memory Usage, thread info, objects info, process status.
I know there is inbuilt python profiler (cprofile) and then there is yappi and others which don't seem to serve my purpose because i want to run these profiler within my application.This way i will be able to view the profiler results and take necessary action (eg - stopping the application whenever CPU usage goes above a certain threshold)
My application is designed to run on Linux as a backgroud process.
Related
In an android kivy app I need to make some heavy computations that do not release GIL. I'd like the app to remain responsive. I also need to be able to cancel the operation. The obvious choice seems to run it in a separate process and use shared memory for the cancel flag. But it does not work since android does not have /dev/shm. Is there a way to get hold of android's shared memory from python?
I have a somewhat different problem to solve with threads in Python.
I have a Python application that talks to very high-speed hardware through a polling interface. I would like the Python process to "own" one of the CPUs, that is, I don't want the Python application to share its CPU with any other process.
What I am currently seeing is that my application gets put "on hold" for tens of milliseconds at a time while it is servicing hardware that executes commands in tens of microseconds, thus the hardware goes idle while my Python application is put on hold.
I am running under Windows 10. Is there a system call of some kind that lets me own the CPU?
I am running some python scripts in my linux terminal that happen to be pretty resource intensive, but when I do my system will become pretty non-responsive until the process has completed. I know there are commands like nice and cpulimit but I haven't found a great way to just open a terminal that is somehow resource limited (and what percentage of resources can be devoted to it) and can be used to run any scripts during that particular session.
So is there a good way to do this?
I was wondering if there is a module that allows the program to see what tasks are running. For example, if I am running Google Chrome, Python Idle, and the program, it should see all 3. (It is most important that it can see its self.)
psutil
psutil is a module providing an interface for retrieving information on all running processes and system utilization (CPU, disk, memory, network) in a portable way by using Python.
I'm developing a long-running multi-threaded Python application for Windows, and I want the process to know the CPU time that each of its threads has taken. I can get the overall times for the entire process with os.times() but I need to know the per-thread times.
I know that there are external tools such as the Sysinternals Process Explorer, but my program itself needs to have this information. If I were on Linux, I look in the /proc filesystem, as described here. If I were writing C code, I'd use the GetThreadTimes call, as described here.
So how can I accomplish this on Windows using Python?
win32process.GetThreadTimes
You want the Python for Windows Extensions to do hairy windows things.
Or you can simply use yappi. (https://code.google.com/p/yappi/) It transparently uses GetThreadTimes() if CPU clock type is selected for profiling.
See here also for an example: https://code.google.com/p/yappi/wiki/YThreadStats_v082