Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Share a temp table in child process using Net::Server

by james2vegas (Chaplain)
on Feb 25, 2010 at 07:03 UTC ( [id://825249]=note: print w/replies, xml ) Need Help??


in reply to Share a temp table in child process using Net::Server

From DBD::Pg:
ATTRIBUTES COMMON TO ALL HANDLES InactiveDestroy (boolean) If set to true, then the "disconnect" method will not be automatically called when the database handle goes out of scope. This is required if you are forking, and even then you must tread carefully and ensure that either the parent or the child (but not both!) handles all database calls from that point forwards, so that messages from the Postgres backend are only handled by one of the processes. If you don't set things up properly, you will see messages such as "server closed the connection unexpectedly", and "message type 0x32 arrived from server while idle". The best solution is to either have the child process reconnect to the database with a fresh database handle, or to rewrite your application not to use use forking. See the section on "Asynchronous Queries" for a way to have your script continue to work while the database is processing a request.
so sharing the database handle between children will not work. You weren't exactly clear on what you meant by having access to the table, but since it is temporary, it will be destroyed at the end of the session and so re-opening the database handle for each forked child will not work either. Perhaps you should create a non-temporary table, re-open the database handle in each child and drop the table when your parent process exits. Alternatively you could use a different Net::Server personality, like Net::Server::Multiplex, which doesn't fork.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://825249]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-04-18 21:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found