Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3cb3501

Browse files
author
Sofia Kopikova
committed
Catch FileNotFoundError exception
When we want to find some Postgres process in testgres psutils lib first gets list of all system processes (children() function in testgres's auxiliary_processes). Next testgres asks for process name (cmdline() function), so psutils goes to /proc/pid/ in Linux. In case any of processes listed in previous step, we get FileNotFoundError
1 parentceb1ee9 commit3cb3501

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎testgres/enums.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ def from_process(process):
6868
],
6969
}# yapf: disable
7070

71+
try:
72+
cmdline=''.join(process.cmdline())
73+
except (FileNotFoundError,ProcessLookupError):
74+
returnProcessType.Unknown
75+
7176
# we deliberately cut special words and spaces
72-
cmdline=''.join(process.cmdline()) \
73-
.replace('postgres:','',1) \
74-
.replace('bgworker:','',1) \
75-
.replace(' ','')
77+
cmdline=cmdline.replace('postgres:','',1) \
78+
.replace('bgworker:','',1) \
79+
.replace(' ','')
7680

7781
forptypeinProcessType:
7882
ifcmdline.startswith(ptype.value.replace(' ','')):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp