On Sun, Jun 20, 2010 at 15:10, yoav glazner <[email protected]> wrote:
> Hi,
> I have a problem in my program, i can replacte it this way:
> <code>
> from elixir import *
> class Job(Entity):
>   number = Field(Integer)
> def f(job):
>   job.expire()
>   job.number
> metadata.bind = "oracle://user:passw...@db"
> setup_all()
> job = Job.query.get(1) #number is primary key
> thread.start_new(f,(job,))
> thread.start_new(f,(job,))
> time.sleep(4)
> </code>
> ok now i get this:
> AttributeError: expired_attributes
> how should i approch this?
> (I know that if i put a lock on function "f" it doesn't happen...)

As far as I know, you shouldn't share a particular object instance
between several threads.

The answer to the question: "Is the session thread-safe?" in:

http://www.sqlalchemy.org/docs/session.html#frequently-asked-questions

applies to your case. But you can perfectly load the same row in two
different threads... If both threads can write, you'll have to
implement some kind of synchronisation mechanism though.

-- 
Gaëtan de Menten

-- 
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en.

Reply via email to