I am using rpyc (v 3.3.0) to get the list of processes running on a remote server using psutil module. My code is as below.
server='hkl20056309'
rpcClient = rpyc.classic.connect(server)
rpsutil = rpcClient.modules.psutil
procs = rpsutil.get_process_list()
I am getting the list of procs correctly but some of the processes attributes are not set correctly. for example:
>>> procs[166]._name
'mingetty'
>>> procs[140]._name
>>> procs[141]._name
>>> procs[142]._name
>>> procs[142]
<psutil.Process(pid=1828, name='gatengine') at 17483536>
>>> procs[142]._name
'gatengine'
>>>
If you see procs[142]._name
is not printed (value is None
) until I access the object. If I print all the processes, I see the name as None for 143rd process object in the list. But after I access the object, suddenly I can see the correct value for the name.
Any suggestions on how I can resolve this issue?