Fix very high cpu usage when a console fenrir under root and an x fenrir under your user are running at the same time.
This commit is contained in:
@@ -12,6 +12,7 @@ import time
|
||||
|
||||
|
||||
INSTANCE_TIMEOUT_SEC = 30.0
|
||||
REGISTRY_DIR_MODE = 0o1777
|
||||
|
||||
|
||||
def get_registry_dir():
|
||||
@@ -26,8 +27,8 @@ def get_instance_file(pid=None):
|
||||
|
||||
def write_instance(instance_data):
|
||||
registry_dir = get_registry_dir()
|
||||
os.makedirs(registry_dir, mode=0o755, exist_ok=True)
|
||||
os.chmod(registry_dir, 0o755)
|
||||
os.makedirs(registry_dir, mode=REGISTRY_DIR_MODE, exist_ok=True)
|
||||
os.chmod(registry_dir, REGISTRY_DIR_MODE)
|
||||
prune_stale_instances()
|
||||
instance_data["updated_at"] = time.time()
|
||||
instance_path = get_instance_file(instance_data.get("pid"))
|
||||
|
||||
@@ -114,6 +114,17 @@ class driver(remoteDriver):
|
||||
}
|
||||
remoteInstanceRegistry.write_instance(instance_data)
|
||||
|
||||
def _try_register_instance(self):
|
||||
try:
|
||||
self._register_instance()
|
||||
return True
|
||||
except Exception as e:
|
||||
self.env["runtime"]["DebugManager"].write_debug_out(
|
||||
"unixDriver could not register instance: " + str(e),
|
||||
debug.DebugLevel.ERROR,
|
||||
)
|
||||
return False
|
||||
|
||||
def _socket_file_matches_socket(self, fenrir_sock, socket_file):
|
||||
try:
|
||||
if os.stat(socket_file).st_uid != os.getuid():
|
||||
@@ -328,11 +339,11 @@ class driver(remoteDriver):
|
||||
if not self.fenrirSocks:
|
||||
return
|
||||
|
||||
self._register_instance()
|
||||
self._try_register_instance()
|
||||
last_register = time.time()
|
||||
while active.value:
|
||||
if time.time() - last_register > 10.0:
|
||||
self._register_instance()
|
||||
self._try_register_instance()
|
||||
last_register = time.time()
|
||||
|
||||
# Check if the client is still connected and if data is available:
|
||||
|
||||
Reference in New Issue
Block a user