[sqlalchemy] Re: obtaining pid of forked process

2010-02-12 Thread Faheem Mitha
On Fri, 12 Feb 2010 13:33:01 +0100, Alex Brasetvik a...@brasetvik.com wrote:

 On Feb 11, 2010, at 18:58 , Faheem Mitha wrote:

 sqlalchemy forks a process when it calls the db

 No, it does not.

 PostgreSQL forks a new backend process when a connection is
  established, however. It sounds like that's what you want. Do
  SELECT pg_backend_pid() to get the PID of the backend process
  serving your connection.

 That and other stat functions are documented here:
  http://www.postgresql.org/docs/current/static/monitoring-stats.html

I see. Thanks, that's very helpful. Does the pid/process stay the same
across successive calls to text()? I'm guessing that successive calls
to text() would take place within the same session, and therefore
correspond to the same backend session.

If not, how can I get it to return the pid before I start the actual
query? In any case, I'll experiment with this.
 
Regards, Faheem.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



[sqlalchemy] Re: obtaining pid of forked process

2010-02-12 Thread Faheem Mitha
On Thu, 11 Feb 2010 13:06:03 -0500, Michael Bayer
mike...@zzzcomputing.com wrote:

 Faheem Mitha wrote:

 Hi,

 sqlalchemy forks a process when it calls the db (in my case PostgreSQL,
 but I don't think it matters) using, for example

 from sqlalchemy.sql import text
 s = text(...)

 um, what ? there's no forking in SQLAlchemy.

Ok. Apologies for my cluelessness.

  Regards, Faheem.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



Re: [sqlalchemy] Re: obtaining pid of forked process

2010-02-12 Thread Michael Bayer
Faheem Mitha wrote:
 PostgreSQL forks a new backend process when a connection is
   established, however. It sounds like that's what you want. Do
   SELECT pg_backend_pid() to get the PID of the backend process
   serving your connection.

 That and other stat functions are documented here:
   http://www.postgresql.org/docs/current/static/monitoring-stats.html

 I see. Thanks, that's very helpful. Does the pid/process stay the same
 across successive calls to text()? I'm guessing that successive calls
 to text() would take place within the same session, and therefore
 correspond to the same backend session.

 If not, how can I get it to return the pid before I start the actual
 query? In any case, I'll experiment with this.


you would connect:

conn = engine.connect()

check the PID:

pid = conn.execute(SELECT pg_backend_pid()).scalar()


then continue as needed:

conn.execute(text(...))





 Regards, Faheem.

 --
 You received this message because you are subscribed to the Google Groups
 sqlalchemy group.
 To post to this group, send email to sqlalch...@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.



-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.



[sqlalchemy] Re: obtaining pid of forked process

2010-02-12 Thread Faheem Mitha
On Fri, 12 Feb 2010 11:01:23 -0500, Michael Bayer
mike...@zzzcomputing.com wrote:

 you would connect:

 conn = engine.connect()

 check the PID:

 pid = conn.execute(SELECT pg_backend_pid()).scalar()


 then continue as needed:

 conn.execute(text(...))

Thanks, Michael. That's very clear and helpful.

   Regards, Faheem.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@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.