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

pantsbuild / pants / 24164262159

08 Apr 2026 11:36PM UTC coverage: 85.889% (-7.0%) from 92.91%
24164262159

Pull #23238

github

web-flow
Merge 88d90acad into 5a129def6
Pull Request #23238: TypeScript: `prettier fmt` crashes with resolve in subdirectory

3 of 3 new or added lines in 1 file covered. (100.0%)

5412 existing lines in 246 files now uncovered.

72530 of 84446 relevant lines covered (85.89%)

3.13 hits per line

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

73.91
/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
8✔
5
import logging
8✔
6
import os
8✔
7
import sys
8✔
8

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

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

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

16

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

20

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

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

30
    @property
8✔
31
    def missing_message_output(self):
8✔
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."
×
33

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

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

57
        return self.acquired
5✔
58

59
    def release(self):
8✔
60
        logger.debug(f"releasing lock: {self!r}")
5✔
61
        if self.acquired:
5✔
62
            safe_delete(self.message_path)
5✔
63
        return super().release()
5✔
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