Not sure if this error is cogen-related but I have never seen it with paste in general

14 views
Skip to first unread message

TK

unread,
Jun 2, 2010, 6:36:03 AM6/2/10
to cogen
In my program I basically sending lots of strings through a cogen
messageQueue.

Once in a while, very rarely, I get this:

Traceback (most recent call last):
File "build/bdist.macosx-10.6-universal/egg/cogen/web/wsgi.py", line
450, in run
for chunk in response:
File "build/bdist.macosx-10.6-universal/egg/cogen/web/async.py",
line 130, in __call__
for i in iterator:
File "/Users/sgt/bin/pylons/lib/python2.6/site-packages/
Paste-1.7.3.1-py2.6.egg/paste/registry.py", line 430, in
streaming_iter
reg.cleanup()
File "/Users/sgt/bin/pylons/lib/python2.6/site-packages/
Paste-1.7.3.1-py2.6.egg/paste/registry.py", line 345, in cleanup
stacked._pop_object(obj)
File "/Users/sgt/bin/pylons/lib/python2.6/site-packages/
Paste-1.7.3.1-py2.6.egg/paste/registry.py", line 233, in _pop_object
'expected (%s)' % (popped, obj))
AssertionError: The object popped ({'_accessed_time':
1275474656.6737311, '_creation_time': 1275474656.6737311}) is not the
same as the object expected ({'_accessed_time': 1275474646.930016,
'_creation_time': 1275474646.930016})

I am not sure if that is related to the messageQueue at all.

Any idea what I should look for. Could this be a bug in Cogen, or in
Paste, or my code?

Ionel Maries Cristian

unread,
Jun 2, 2010, 7:37:24 AM6/2/10
to co...@googlegroups.com
Paste registry relies heavily on thread locals. Of-course, cogen
doesn't have threads but monkey patches paste.util.threadinglocal
(see: http://code.google.com/p/cogen/source/browse/trunk/cogen/web/wsgi.py#789
).

Can you verify that "paste.util.threadinglocal.local is cogen.web.wsgi.local" ?

Also, are you using threads for anything (that involves those registries) ?

-- ionel

TK

unread,
Jun 2, 2010, 10:31:16 AM6/2/10
to cogen
Well basically I found what triggered it. I have a request that is
send called "STANDBY", and it waits for a message on the queue if
there is anything there. I found that the client requested "STANDBY"
twice, and my system didn't handle that very well. As long as he only
requests it once, it does not trigger any error at all. I'm still
investigating exactly what happened but the error messages are just
confusing. It's basically things like this:

The object popped ({'_accessed_time': 1275484780.9650331,
'_creation_time': 1275484780.9650331}) is not the same as the object
expected ({'_accessed_time': 1275484780.9652359, '_creation_time':
1275484780.9652359})

Btw, I did :
from paste.util import threadinglocal
from cogen.web.wsgi import local
print "equal?", (threadinglocal == local)

It results in equal? False

I'm not using threads for anything, only cogen.

Regards,
TK

TK

unread,
Jun 2, 2010, 10:40:30 AM6/2/10
to cogen
> Btw, I did :
>     from paste.util import threadinglocal
>     from cogen.web.wsgi import local
>     print "equal?", (threadinglocal == local)
>
> It results in equal? False
Correction: I did this test before the local was assigned. It's
actually equal, as per the Cogen docs for usage with Pylons.

Ionel Maries Cristian

unread,
Jun 2, 2010, 12:10:24 PM6/2/10
to co...@googlegroups.com
I'm curious how the pylons handler for STANDBY looks like.

-- ionel

> --
> You received this message because you are subscribed to the Google Groups "cogen" group.
> To post to this group, send email to co...@googlegroups.com.
> To unsubscribe from this group, send email to cogen+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cogen?hl=en.
>
>

TK

unread,
Jun 2, 2010, 3:19:46 PM6/2/10
to cogen
Will send tomorrow, got the code at work. :)

TK

unread,
Jun 3, 2010, 7:07:55 AM6/3/10
to cogen

Here it is. Note that Jcb is just the name of a JavaScript callback
function, and not relevant. `query' here always returns JSON.

def query(self):
""" This is in the controller """
<various irrelevant stuff removed>
resultMessage = processStandbyMessage (
__jcb,
request.environ['cogen.call'],
activityID, agent, _msg
)
<various stuff removed>
return resultMessage

def processStandbyMessage(jcb, cogenCall, activityID, agent, msg):
""" Client sent standby, so we just idle for a while and if we
have
some data available, we send it """

# We check the agent's own messageQueue, and timeout in 10 seconds
yield cogenCall (agent.messageQueue.get)(timeout=10)
resultMessage = request.environ['cogen.wsgi'].result
if resultMessage:
if isinstance(resultMessage, events.OperationTimeout):
yield jcb + '(' + IdleMessage().tojson() + ');'
elif isinstance(resultMessage, Exception):
yield jcb + '(' + ErrorMessage("Exception
caught").tojson() + ');'
elif isinstance(resultMessage, BaseOutgoingMessage):
yield jcb + '(' + resultMessage.tojson() + ');'
else:
yield jcb + '(' + ErrorMessage("Got unknown message type
from data process called " +
type(resultMessage).__name__).tojson()
+ ');'
cur.close()
return

cur.close()
yield jcb + '(' + IdleMessage().tojson() + ');'

The main point is that the agent.messageQueue gets modified
(via .put()) from another Cogen routine.

It still seems to work now, as long as the client doesn't send two
STANDBY requests.

Ionel Maries Cristian

unread,
Jun 3, 2010, 8:14:00 AM6/3/10
to co...@googlegroups.com
This doesn't look suspicious (mind the fact that you're discarding
exception messages :). Could there be a case where you would start a
coroutine and pass it some of the paste/pylons's request/state objects
and mutate them ? That would be plausible since each coroutine has a
different ident - and thus, the 'local' objects would act differently
for each one.

-- ionel

Reply all
Reply to author
Forward
0 new messages