-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
I'm clearly being an idiot but can't figure out how/where. I've had a
look through parts of the SA code but aren't getting any closer to
finding what is causing my problem.
The synopsis of the problem:
engine = ProxyEngine()
jobs = Table("Jobs", engine,
Column("job_id", Integer, primary_key),
Column("job_pid", Integer, key="pid"),
Column("job_exit_code", Integer, key="exit_code"),
....)
job_params = Table("job_params", engine,
Column("job_id", Integer, ForeignKey("jobs.job_id"), primary_key=True),
Column("param_name", String, key="name", primary_key=True),
Column("param_value", String key="value"))
class JobParam:
def __init__(self, name=None, value=None):
self.name = name
self.value = value
JobParam.mapper = mapper(JobParam, job_params)
class Job:
def __init__(self, name=None, pid=None, exit_code=None,
start_time=None, ...):
self.name = name
self.pid = pid
...
Job.mapper = mapper(Job, jobs, properties={"params":
relation(JobParam.mapper, private=True)})
def Connect():
"Connect to the database."
global engine
engine.connect("postgres", {"database": "fred", "host": "localhost",
"user": "test", "password": "test"})
Connect()
....
for job in Job.mapper.select(and_(jobs.c.start_time == None, jobs.c.pid
== None), order_by=[asc(Job.mapper.c.create_time)]):
pid = os.fork()
if pid:
job.pid = pid
job.start_time = mx.DateTime.now()
objectstore.commit()
else:
Connect()
# Query & update other tables in the database.
# Spawn other processes via subprocess.call()
os._exit(return_code)
The problem is that the commit in the parent process fails with a
psycopg error (ProgrammingError: "SET TRANSACTION ISOLATION LEVEL...")
when trying to update the PID, etc (but only if it has started more
than 1 child).
I'm using version 0.1.4. of SA (planning to update but can't at the
moment). I need to use fork() as I want the parent process to be
totally isolated from the child processes (which may die with SEGV or
similar as they do potentially naughty things via other programs).
I realize this isn't a very good explanation (I'll try to get a simple
test case together to illustrate) but was hoping some-one could point
me in the right direction before then :-)
Many thanks
Alan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
iD8DBQFEYgwlKJDmEytdZIcRAsCWAKCOJWZiCalQ8UWknAIUSK8IftepWgCdGS98
YP7QX+M6BXlF+WuilHt9fnM=
=TUmY
-----END PGP SIGNATURE-----
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users