you should create a new engine per forked process, within the forked  
process, and bind it to the session.    Using the connection pool from  
the parent process in a child fork does not produce behavior that's  
defined in any way I'm aware of (apparently the connections travel  
over for this particular DBAPI).

Alternatively, you can try using the NullPool pool implementation  
which does not pool any connections.  It will open and close  
connections for real without storing them in any kind of queue.

On Jan 15, 2009, at 1:53 PM, mg wrote:

>
> Hi,
> I am using SA inside of a couple of scripts that use pyprocessing to
> spawn off children. It looks like it's working, but occasionally I get
> some really odd errors. Here are the basics of the app:
> We are using the declarative layer, SA5, etc. At runtime, a parameter
> is passed in that gives the db to connect to.
>
> Pseudocode:
> Session = scoped_session(sessionmaker(autocommit=True,
> autoflush=True))
> ...
> main.py
> Session.configure(bind=engine)
>
> manager = processing.Process(target=manager,
>                                name='manager',
>                                args=(mailing_id))
> manager.start()
>
> manager.py
> from main import Session
> session = Session()
> worker = processing.Process(target=worker)
> worker.start()
>
> worker.py
> from main import Session
> session = Session()
>
> If I call Session.bind.dispose() at any point, any queries in the
> forked processes seem to get the following errors:
> ProgrammingError: (ProgrammingError) server closed the connection
> unexpectedly
>        This probably means the server terminated abnormally
>        before or while processing the request.
>
> Any ideas would be very helpful
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to