Blocking Call In Async (ARCH9028)
Key swift.async.blocking-call-in-async · Severity error · Category async
Flags sleep(), Thread.sleep and usleep inside async functions - they block a cooperative-pool thread instead of suspending.
Incorrect
Section titled “Incorrect”func poll() async { sleep(1)}Correct
Section titled “Correct”func poll() async throws { try await Task.sleep(for: .seconds(1))}Use Task.sleep.