Skip to content

Commit e92df2d

Browse files
authored
Revert of "Lock scratch directory during tool execution" (#7286)
We're seeing hangs in self-hosted jobs since merging this and I can't repro locally, so let's try this speculative revert to see whether it resolves the issues. Reverts #7269
1 parent e5dbd8d commit e92df2d

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

Sources/Basics/FileSystem/FileSystem+Extensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ extension FileSystem {
196196
}
197197

198198
/// Execute the given block while holding the lock.
199-
public func withLock<T>(on path: AbsolutePath, type: FileLock.LockType, blocking: Bool = true, _ body: () throws -> T) throws -> T {
200-
try self.withLock(on: path.underlying, type: type, blocking: blocking, body)
199+
public func withLock<T>(on path: AbsolutePath, type: FileLock.LockType, _ body: () throws -> T) throws -> T {
200+
try self.withLock(on: path.underlying, type: type, body)
201201
}
202202

203203
/// Returns any known item replacement directories for a given path. These may be used by platform-specific

Sources/CoreCommands/SwiftTool.swift

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import func TSCBasic.exec
4141
import protocol TSCBasic.OutputByteStream
4242
import class TSCBasic.Process
4343
import enum TSCBasic.ProcessEnv
44-
import enum TSCBasic.ProcessLockError
4544
import var TSCBasic.stderrStream
4645
import class TSCBasic.TerminalController
4746
import class TSCBasic.ThreadSafeOutputByteStream
@@ -109,27 +108,14 @@ extension SwiftCommand {
109108
workspaceLoaderProvider: self.workspaceLoaderProvider
110109
)
111110
swiftTool.buildSystemProvider = try buildSystemProvider(swiftTool)
112-
113-
// Try a non-blocking lock first so that we can inform the user about an already running SwiftPM.
114-
do {
115-
try swiftTool.fileSystem.withLock(on: swiftTool.scratchDirectory, type: .exclusive, blocking: false) {}
116-
} catch let ProcessLockError.unableToAquireLock(errno) {
117-
if errno == EWOULDBLOCK {
118-
swiftTool.outputStream.write("Another instance of SwiftPM is already running using '\(swiftTool.scratchDirectory)', waiting until that process has finished execution...".utf8)
119-
swiftTool.outputStream.flush()
120-
}
121-
}
122-
123111
var toolError: Error? = .none
124-
try swiftTool.fileSystem.withLock(on: swiftTool.scratchDirectory, type: .exclusive) {
125-
do {
126-
try self.run(swiftTool)
127-
if swiftTool.observabilityScope.errorsReported || swiftTool.executionStatus == .failure {
128-
throw ExitCode.failure
129-
}
130-
} catch {
131-
toolError = error
112+
do {
113+
try self.run(swiftTool)
114+
if swiftTool.observabilityScope.errorsReported || swiftTool.executionStatus == .failure {
115+
throw ExitCode.failure
132116
}
117+
} catch {
118+
toolError = error
133119
}
134120

135121
// wait for all observability items to process

0 commit comments

Comments
 (0)