mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Do not use deprecated psutil API
This commit is contained in:
parent
fa85e21967
commit
8b16eeac34
@ -15,18 +15,11 @@ value.
|
|||||||
|
|
||||||
import gc, os
|
import gc, os
|
||||||
|
|
||||||
from calibre.constants import iswindows, islinux
|
|
||||||
|
|
||||||
def get_memory():
|
def get_memory():
|
||||||
'Return memory usage in bytes'
|
'Return memory usage in bytes'
|
||||||
|
# See https://pythonhosted.org/psutil/#psutil.Process.memory_info
|
||||||
import psutil
|
import psutil
|
||||||
p = psutil.Process(os.getpid())
|
return psutil.Process(os.getpid()).memory_info().rss
|
||||||
if hasattr(p, 'memory_info_ex'):
|
|
||||||
mem = p.memory_info_ex()
|
|
||||||
else:
|
|
||||||
mem = p.get_ext_memory_info()
|
|
||||||
attr = 'wset' if iswindows else 'data' if islinux else 'rss'
|
|
||||||
return getattr(mem, attr)
|
|
||||||
|
|
||||||
def memory(since=0.0):
|
def memory(since=0.0):
|
||||||
'Return memory used in MB. The value of since is subtracted from the used memory'
|
'Return memory used in MB. The value of since is subtracted from the used memory'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user