From: Robert Klemme Date: 2008-03-27T21:40:09+09:00 Subject: Re: fork 2008/3/27, Joey Marino : > I have a class to handle interfacing to the database. The initialization of > the class will connect to the db and another method will close the > connection and there are query functions for handling the queries and > results. This object is then passed into new objects on their > initialization. This cannot possibly work, as you have discovered. You need to open DB connections in child processes individually because there are usually socket connections involved and you cannot share the same connection between processes because the DB needs to keep them separate even though you can share the client socket. > The problem comes in when I iterate through a set of objects > creating a fork for each one. After the first object I am getting a > "database went away error". My code looks like the following: > I know I am missing a key concept here. This is the first time I have worked > with forked processes. See above. Kind regards robert -- use.inject do |as, often| as.you_can - without end