Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="https://github.com/giampaolo/psutil" rel="noreferrer">psutil</a> is a cross-platform library that retrieves information about running processes and system utilization.</p> <pre class="lang-python prettyprint-override"><code>import psutil pythons_psutil = [] for p in psutil.process_iter(): try: if p.name() == 'python.exe': pythons_psutil.append(p) except psutil.Error: pass </code></pre> <pre class="lang-none prettyprint-override"><code>&gt;&gt;&gt; pythons_psutil [&lt;psutil.Process(pid=16988, name='python.exe') at 25793424&gt;] &gt;&gt;&gt; print(*sorted(pythons_psutil[0].as_dict()), sep='\n') cmdline connections cpu_affinity cpu_percent cpu_times create_time cwd exe io_counters ionice memory_info memory_info_ex memory_maps memory_percent name nice num_ctx_switches num_handles num_threads open_files pid ppid status threads username &gt;&gt;&gt; pythons_psutil[0].memory_info() pmem(rss=12304384, vms=8912896) </code></pre> <hr> <p>In a stock Windows Python you can use <code>subprocess</code> and <code>csv</code> to parse the output of <code>tasklist.exe</code>:</p> <pre class="lang-python prettyprint-override"><code>import subprocess import csv p_tasklist = subprocess.Popen('tasklist.exe /fo csv', stdout=subprocess.PIPE, universal_newlines=True) pythons_tasklist = [] for p in csv.DictReader(p_tasklist.stdout): if p['Image Name'] == 'python.exe': pythons_tasklist.append(p) </code></pre> <pre class="lang-none prettyprint-override"><code>&gt;&gt;&gt; print(*sorted(pythons_tasklist[0]), sep='\n') Image Name Mem Usage PID Session Name Session# &gt;&gt;&gt; pythons_tasklist[0]['Mem Usage'] '11,876 K' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload