summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-07-23 14:55:30 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-08-16 15:42:35 +0000
commitedfb540227f22de4355daf07eb6e2480345883aa (patch)
tree0adf380e523853ca9ce4ceee2621b581942c9e00
parent1f7020266ee794643e486e4a15fb83916f69fcfc (diff)
downloadbuildstream-edfb540227f22de4355daf07eb6e2480345883aa.tar.gz
utils: uppercase global _MAIN_PID, move to top
This is consistent with the other global vars in the module.
-rw-r--r--src/buildstream/utils.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py
index 2c57925d4..b78c25871 100644
--- a/src/buildstream/utils.py
+++ b/src/buildstream/utils.py
@@ -52,6 +52,9 @@ BST_ARBITRARY_TIMESTAMP = calendar.timegm([2011, 11, 11, 11, 11, 11])
_ALIAS_SEPARATOR = ':'
_URI_SCHEMES = ["http", "https", "ftp", "file", "git", "sftp", "ssh"]
+# Main process pid
+_MAIN_PID = os.getpid()
+
class UtilError(BstError):
"""Raised by utility functions when system calls fail.
@@ -699,17 +702,13 @@ def _pretty_size(size, dec_places=0):
return "{size:g}{unit}".format(size=round(psize, dec_places), unit=unit)
-# Main process pid
-_main_pid = os.getpid()
-
-
# _is_main_process()
#
# Return whether we are in the main process or not.
#
def _is_main_process():
- assert _main_pid is not None
- return os.getpid() == _main_pid
+ assert _MAIN_PID is not None
+ return os.getpid() == _MAIN_PID
# Recursively remove directories, ignoring file permissions as much as