Did I find the right examples for you? yes no

All Samples(129)  |  Call(124)  |  Derive(0)  |  Import(5)
Return a generator yielding a Process instance for all
running processes.

Every new Process instance is only created once and then cached
into an internal table which is updated every time this is used.

Cached Process instances are checked for identity so that you're
safe in case a PID has been reused by another process, in which
case the cached instance is updated.
(more...)

        def process_iter():
    """Return a generator yielding a Process instance for all
    running processes.

    Every new Process instance is only created once and then cached
    into an internal table which is updated every time this is used.

    Cached Process instances are checked for identity so that you're
    safe in case a PID has been reused by another process, in which
    case the cached instance is updated.

    The sorting order in which processes are yielded is based on
    their PIDs.
    """
    def add(pid):
        proc = Process(pid)
        _pmap[proc.pid] = proc
        return proc

    def remove(pid):
        _pmap.pop(pid, None)

    a = set(pids())
    b = set(_pmap.keys())
    new_pids = a - b
    gone_pids = b - a

    for pid in gone_pids:
        remove(pid)
    for pid, proc in sorted(list(_pmap.items()) +
                            list(dict.fromkeys(new_pids).items())):
        try:
            if proc is None:  # new process
                yield add(pid)
            else:
                # use is_running() to check whether PID has been reused by
                # another process in which case yield a new Process instance
                if proc.is_running():
                    yield proc
                else:
                    yield add(pid)
        except NoSuchProcess:
            remove(pid)
        except AccessDenied:
            # Process creation time can't be determined hence there's
            # no way to tell whether the pid of the cached process
            # has been reused. Just return the cached version.
            yield proc
        


src/p/s/psutil-2.1.1/examples/iotop.py   psutil(Download)
    """
    # first get a list of all processes and disk io counters
    procs = [p for p in psutil.process_iter()]
    for p in procs[:]:
        try:

src/p/s/psutil-2.1.1/examples/netstat.py   psutil(Download)
        "Program name"))
    proc_names = {}
    for p in psutil.process_iter():
        try:
            proc_names[p.pid] = p.name()

src/p/s/psutil-HEAD/examples/iotop.py   psutil(Download)
    """
    # first get a list of all processes and disk io counters
    procs = [p for p in psutil.process_iter()]
    for p in procs[:]:
        try:

src/p/s/psutil-2.1.1/examples/top.py   psutil(Download)
    procs = []
    procs_status = {}
    for p in psutil.process_iter():
        try:
            p.dict = p.as_dict(['username', 'nice', 'memory_info',

src/p/s/psutil-HEAD/examples/top.py   psutil(Download)
    procs = []
    procs_status = {}
    for p in psutil.process_iter():
        try:
            p.dict = p.as_dict(['username', 'get_nice', 'get_memory_info',

src/p/s/psutil-2.1.1/examples/killall.py   psutil(Download)
 
    killed = []
    for proc in psutil.process_iter():
        if proc.name() == NAME and proc.pid != os.getpid():
            proc.kill()

src/p/s/psutil-HEAD/examples/netstat.py   psutil(Download)
def main():
    templ = "%-5s %-22s %-22s %-13s %-6s %s"
    print_(templ % ("Proto", "Local addr", "Remote addr", "Status", "PID",
                    "Program name"))
    for p in psutil.process_iter():

src/p/s/psutil-HEAD/examples/killall.py   psutil(Download)
 
    killed = []
    for proc in psutil.process_iter():
        if proc.name == NAME and proc.pid != os.getpid():
            proc.kill()

src/p/s/psdash-0.3.0/psdash/web.py   psdash(Download)
def processes(sort="pid", order="asc"):
    procs = []
    for p in psutil.process_iter():
        rss, vms = p.get_memory_info()
 

src/p/s/psdash-HEAD/psdash/web.py   psdash(Download)
def processes(sort="pid", order="asc"):
    procs = []
    for p in psutil.process_iter():
        rss, vms = p.get_memory_info()
 

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next