[Sensors][proposed patch] sensors.py: Current implementation of bat_get_data very slow
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Individual Screenlets |
New
|
Undecided
|
Unassigned |
Bug Description
Hello,
The current implementation of bat_get_data is extremely slow. It takes around 2 seconds to even 3 sometimes for the function to return. Consequently, this causes any screenlet that uses this function to stall for 2 or 3 seconds. It even causes the preferences window of the screenlet to stall whenever the battery information gets updated.
Instead, I propose we use dbus to obtain the battery information.
Here are the two functions:
def bat_get_
"""Returns battery list"""
"""DBus version"""
try:
system_bus = dbus.SystemBus()
batteries = hal_manager.
return batteries
except:
return[]
def bat_get_
"""Returns battery data"""
"""DBus version"""
try:
total = 0
current = 0
full = 0
state = ''
present = True
system_bus = dbus.SystemBus()
bat_obj = system_
battery = dbus.Interface(
present = battery.
total = battery.
full = battery.
current = battery.
if (battery.
state = "charging"
else:
state = "discharging"
return total, current, full, state, present
except:
return 0, 0, 0, '', False
I have tested this on my machine and there are no more stalls or lags.
There are two proposed patches in the tar file attached: the first one is for sensors.py and the second one is for SysmonitorScree
The second patch modifies SysmonitorScree
Note: In the SysmonitorScreenlet patch, the last modification was added because in my SysmonitorScree
affects: | screenlets → indiv-screenlets |
summary: |
- [proposed patch] sensors.py: Current implementation of bat_get_data very - slow + [Sensors][proposed patch] sensors.py: Current implementation of + bat_get_data very slow |