• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 21552830208

31 Jan 2026 11:40PM UTC coverage: 80.277% (-0.05%) from 80.324%
21552830208

Pull #23062

github

web-flow
Merge 808a9786c into 2c4dcf9cf
Pull Request #23062: Remove support for Get

18 of 25 new or added lines in 4 files covered. (72.0%)

17119 existing lines in 541 files now uncovered.

78278 of 97510 relevant lines covered (80.28%)

3.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.83
/src/python/pants/pantsd/lock.py
1
# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
import errno
12✔
5
import logging
12✔
6
import os
12✔
7
import sys
12✔
8

9
import psutil
12✔
10
from fasteners import InterProcessLock
12✔
11

12
from pants.util.dirutil import safe_delete
12✔
13

14
logger = logging.getLogger(__name__)
12✔
15

16

17
def print_to_stderr(message):
12✔
UNCOV
18
    print(message, file=sys.stderr)
1✔
19

20

21
class OwnerPrintingInterProcessFileLock(InterProcessLock):
12✔
22
    @property
12✔
23
    def message_path(self):
12✔
24
        return f"{self.path_str}.lock_message"
7✔
25

26
    @property
12✔
27
    def path_str(self):
12✔
28
        return self.path.decode()
7✔
29

30
    @property
12✔
31
    def missing_message_output(self):
12✔
UNCOV
32
        return f"Pid {os.getpid()} waiting for a file lock ({self.path_str}), but there was no message at {self.message_path} indicating who is holding it."
1✔
33

34
    def acquire(self, message_fn=print_to_stderr, **kwargs):
12✔
35
        logger.debug(f"acquiring lock: {self!r}")
7✔
36
        super().acquire(blocking=False)
7✔
37
        if not self.acquired:
7✔
UNCOV
38
            try:
1✔
UNCOV
39
                with open(self.message_path, "rb") as f:
1✔
UNCOV
40
                    message = f.read().decode("utf-8", "replace")
1✔
UNCOV
41
                    output = f"PID {os.getpid()} waiting for a file lock ({self.path_str}) held by: {message}"
1✔
UNCOV
42
            except OSError as e:
1✔
UNCOV
43
                if e.errno == errno.ENOENT:
1✔
UNCOV
44
                    output = self.missing_message_output
1✔
45
                else:
46
                    raise
×
UNCOV
47
            message_fn(output)
1✔
UNCOV
48
            super().acquire(**kwargs)
1✔
49

50
        if self.acquired:
7✔
51
            current_process = psutil.Process()
7✔
52
            cmd_line = " ".join(current_process.cmdline())
7✔
53
            message = f"{current_process.pid} ({cmd_line})"
7✔
54
            with open(self.message_path, "wb") as f:
7✔
55
                f.write(message.encode())
7✔
56

57
        return self.acquired
7✔
58

59
    def release(self):
12✔
60
        logger.debug(f"releasing lock: {self!r}")
7✔
61
        if self.acquired:
7✔
62
            safe_delete(self.message_path)
7✔
63
        return super().release()
7✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc