mirror of
https://github.com/clearml/clearml-agent
synced 2025-06-26 18:16:15 +00:00
Fix uid is None causes ValueError in str.startswith(). Fix str.split (should be on the filename itself, not the path).
This commit is contained in:
parent
40b3c1502d
commit
6df0f81ca0
@ -2520,7 +2520,7 @@ class Worker(ServiceCommandSection):
|
|||||||
# Iterate over all running process
|
# Iterate over all running process
|
||||||
for pid, uid, slot, file in sorted(Singleton.get_running_pids(), key=lambda x: x[1] or ''):
|
for pid, uid, slot, file in sorted(Singleton.get_running_pids(), key=lambda x: x[1] or ''):
|
||||||
# wither we have a match for the worker_id or we just pick the first one
|
# wither we have a match for the worker_id or we just pick the first one
|
||||||
if pid >= 0 and (
|
if pid >= 0 and uid is not None and (
|
||||||
(worker_id and uid == worker_id) or
|
(worker_id and uid == worker_id) or
|
||||||
(not worker_id and uid.startswith('{}:'.format(worker_name)))):
|
(not worker_id and uid.startswith('{}:'.format(worker_name)))):
|
||||||
# this is us kill it
|
# this is us kill it
|
||||||
|
@ -4,6 +4,8 @@ from time import sleep
|
|||||||
from glob import glob
|
from glob import glob
|
||||||
from tempfile import gettempdir, NamedTemporaryFile
|
from tempfile import gettempdir, NamedTemporaryFile
|
||||||
|
|
||||||
|
from typing import List, Tuple, Optional
|
||||||
|
|
||||||
from trains_agent.definitions import ENV_DOCKER_HOST_MOUNT
|
from trains_agent.definitions import ENV_DOCKER_HOST_MOUNT
|
||||||
from trains_agent.helper.base import warning
|
from trains_agent.helper.base import warning
|
||||||
|
|
||||||
@ -84,11 +86,12 @@ class Singleton(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_running_pids(cls):
|
def get_running_pids(cls):
|
||||||
|
# type: () -> List[Tuple[int, Optional[str], Optional[int], str]]
|
||||||
temp_folder = cls._get_temp_folder()
|
temp_folder = cls._get_temp_folder()
|
||||||
files = glob(os.path.join(temp_folder, cls.prefix + cls.sep + '*' + cls.ext))
|
files = glob(os.path.join(temp_folder, cls.prefix + cls.sep + '*' + cls.ext))
|
||||||
pids = []
|
pids = []
|
||||||
for file in files:
|
for file in files:
|
||||||
parts = file.split(cls.sep)
|
parts = os.path.basename(file).split(cls.sep)
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
pid = int(parts[1])
|
pid = int(parts[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user