If you have a session and then you fork, the child process is going to
try to use the same session but that won't work because connections
can't be floated across processes. If you call dispose() on the engine
in the child process after forking (e.g., metadata.bind.dispose() ),
then the child will end up creating its own connection and everything
will work fine, assuming you aren't actually trying to have
transactions that span processes (are you?).

On Fri, Sep 19, 2008 at 7:59 PM, cono <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm having problems with a process that uses an sqlAlchemy session,
> and after that it forks. From that moment I have 2 processes (can be
> more) that uses alchemy sessions.
>
> Both processes fails with "ProgrammingError: (ProgrammingError) SET
> TRANSACTION ISOLATION LEVEL must be called before any query".
>
> What happens when I fork (I'm in linux)? My guess is that both process
> share the same socket. (but nowadays I'm not really sure of
> anything...).
>
> If that's the case, my fist solution was to close all file descriptors
> on fork, hoping that alchemy would recreate connections. But it
> failed, I had a "Bad Descriptor" error.
>
> My second approach, was to reconfigure the session with a newly
> created engine with the same configuration options as before. That
> didn't work either, and it gave me the same error of "SET TRANSACTION
> ISOLATION LEVEL". This outcome puzzles me :S
>
> Any ideas? What can I do to fork a process and continue using
> sessions??
>
> Thanks in advance!!
> Mariano Cortesi
> Zauber - Popego
>
> >
>

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

Reply via email to