Skip to content

Commit

Permalink
Merge pull request #566 from sparklemotion/flavorjones-suppress-fork-…
Browse files Browse the repository at this point in the history
…warnings

feat: `SQLite3::ForkSafety.suppress_warnings!`
  • Loading branch information
flavorjones authored Sep 24, 2024
2 parents 4b6d614 + c90b177 commit 81fb037
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/sqlite3/fork_safety.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def _fork

@databases = []
@mutex = Mutex.new
@suppress = false

class << self
def hook!
Expand All @@ -30,7 +31,7 @@ def track(database)
end

def discard
warned = false
warned = @suppress
@databases.each do |db|
next unless db.weakref_alive?

Expand All @@ -49,6 +50,11 @@ def discard
end
@databases.clear
end

# Call to suppress the fork-related warnings.
def suppress_warnings!
@suppress = true
end
end
end
end
Expand Down

0 comments on commit 81fb037

Please sign in to comment.