Skip to content

Commit

Permalink
feat: SQLite3::ForkSafety.suppress_warnings!
Browse files Browse the repository at this point in the history
For frameworks like Rails where it's expected to sometimes fork with
open writable connections.
  • Loading branch information
flavorjones committed Sep 24, 2024
1 parent 4b6d614 commit c90b177
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 c90b177

Please sign in to comment.