Disconnect from DataMapper (DataObjects adapter) before forking?

Using DataMapper, in a process that develops children, I get packet corruption due to the connection to the database still being open (and used) in the parent. I want to force disconnect and reconnect, as you should do when forking, but the DataMapper does not look like it even considered this use case.

Now I am going through a private API, and I had to deal a bit with the internal components and its connection pool so that this is not correct:

DataMapper.repository(:default).adapter.send(:open_connection).dispose

Does anyone know if there is a more “public” and correct way to do this? I asked via IRC, but no one answered.

+3
source share
1 answer

, ,

# Disconnects an existing DataMapper Session
def disconnect!
  DataObjects::Pooling.pools.each do |pool|
    pool.dispose
  end
end
+2

All Articles