File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,17 +35,21 @@ def discard # :nodoc:
3535 @databases . each do |db |
3636 next unless db . weakref_alive?
3737
38- unless db . closed? || db . readonly?
39- unless warned
40- # If you are here, you may want to read
41- # https://github.com/sparklemotion/sqlite3-ruby/pull/558
42- warn ( "Writable sqlite database connection(s) were inherited from a forked process. " \
43- "This is unsafe and the connections are being closed to prevent possible data " \
44- "corruption. Please close writable sqlite database connections before forking." ,
45- uplevel : 0 )
46- warned = true
38+ begin
39+ unless db . closed? || db . readonly?
40+ unless warned
41+ # If you are here, you may want to read
42+ # https://github.com/sparklemotion/sqlite3-ruby/pull/558
43+ warn ( "Writable sqlite database connection(s) were inherited from a forked process. " \
44+ "This is unsafe and the connections are being closed to prevent possible data " \
45+ "corruption. Please close writable sqlite database connections before forking." ,
46+ uplevel : 0 )
47+ warned = true
48+ end
49+ db . close
4750 end
48- db . close
51+ rescue WeakRef ::RefError
52+ # GC may run while this method is executing, and that's OK
4953 end
5054 end
5155 @databases . clear
You can’t perform that action at this time.
0 commit comments