Fernando Takai wrote:
> This is the exact code that is running now:
>
> log.info("Creating proxies for file %s" % job.file)
>
> job = session.merge(job)
>
> if agent.transcoder.run(job.local_filename):
>     log.info("Transcoding finished for file %s" % job.local_filename)
> else:
>     log.error("Occurred a problem while transcoding the file. Please,
> verify the logs.")
>     job.error_status = "Occurred a problem while transcoding the file.
> Please, verify the logs."
>
> (The problem is occurring on the log.info line)
> As you can see, i *am* merging the job on the current session - so, the
> exception shouldn't be happening.
>
> Also, i use the local_filename variable before, so it's not expired
> (afaik).

from that code above, the error message you are seeing is impossible. 
Unless a concurrent thread is calling close() or similar on that session,
perhaps.



>
> On Nov 17, 2009, at 1:35 PM, Michael Bayer wrote:
>
>>
>> Fernando Takai wrote:
>>>
>>> I have changed my code to be like this:
>>>
>>> job = session.merge(job)
>>> # Merge docs says that object does not get into the session
>>> session.add(job)
>>>
>>> log.info("Job finished! %s" % job.file)
>>>
>>> When using latest SQLAlchemy trunk and 0.5.6 sometimes i get
>>> UnboundExecutionError.
>>>
>>> Also, i can assure that all my attributes are loaded - i use all of
>>> them
>>> before and no error occurs.
>>
>> but they may be expired at some point.  If their host session is rolled
>> back or committed, for example.   The stack trace will illustrate
>> exactly
>> what action is initiating the load operation. For example, in the stack
>> trace you posted, the "job.local_filename" attribute is unloaded or
>> expired.  You can test for this by seeing that "local_filename" is not
>> present in job.__dict__.
>>
>>
>>>
>>> Maybe there's something wrong with the way i'm getting the session:
>>>
>>> session = Session.object_session(job)
>>> if not session:
>>>    session = Session()
>>
>> there's nothing "wrong" with it per se except it appears to be guessing
>> as
>> to what session should be used - "well lets see if this object has a
>> session from somewhere, or otherwise we'll just make one, maybe not".
>>
>> Sessions can be created as much as you like but they work best when they
>> are in charge of their scope, i.e.:
>>
>> def do_something():
>>    # build the one session we care about for this thread/operation
>>    sess = session()
>>
>>    # ensure everyone from outside is merged into our one session
>>    o1 = sess.merge(o1)
>>    o2 = sess.merge(o2)
>>    o3 = sess.merge(o3)
>>
>>    # commit with authority
>>    sess.commit()
>>
>>
>> as opposed to:
>>
>> def do_something():
>>    s1 = object_session(o1) or Session()
>>    s2 = object_session(o2) or Session()
>>    s3 = object_session(o3) or Session()
>>
>>    s3.commit()
>>    s2.commit() ?  or no ?  where did this session come from ?
>>
>>
>>
>>
>>
>>
>> --~--~---------~--~----~------------~-------~--~----~
>> 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
>> -~----------~----~----~----~------~----~------~--~---
>>
>
> --
> Fernando Takai
> http://twitter.com/fernando_takai
>
>
>
>
>
> --
>
> 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.
>
>
>

--

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