[Soap-Python] rpclib - very strange problem

azurIt azurit at pobox.sk
Tue Dec 6 19:59:40 CET 2011


Good news everyone! :D

Burak i now EXACTLY know why this all is happening and i only don't know how to easily fix it (but i'm sure you will have some ideas). Here is my code which is run if user cannot be authenticated (= so it is run if i remove my session from DB and try to access API):

def cannot_auth_function(ctx, state):
        return {"state": state}

def run_before_auth(ctx):
        ...
        if not perm:
                ctx.descriptor.function = cannot_auth_function
                ctx.in_object = (perm["state"],)

director_auth.event_manager.add_listener("method_call", run_before_auth)


Problem is that ctx.descriptor.function is probably pointer to real function which gets permanently (=until it is reloaded into memory) replaced by cannot_auth_function. Any hints how should i do this correctly ? :)

azur



______________________________________________________________
> Od: "azurIt" <azurit at pobox.sk>
> Komu: <soap at python.org>
> Dátum: 06.12.2011 19:22
> Predmet: Re: [Soap-Python] rpclib - very strange problem
>
>little more info:
> - the process which gets crazy is the one which was used as last (so, when i set wsgi to use only one process, 100% of requests are invalid)
> - upgrading mod_wsgi to the newest version didn't fix anything
>
>Burak, are you 100% sure this can't be rpclib problem ?
>
>
>
>______________________________________________________________
>> Od: "Burak Arslan" <burak.arslan at arskom.com.tr>
>> Komu: azurIt <azurit at pobox.sk>
>> Dátum: 06.12.2011 18:52
>> Predmet: Re: [Soap-Python] rpclib - very strange problem
>>
>> CC: soap at python.org
>>On 12/06/11 19:48, azurIt wrote:
>>> Burak, i got something!! :) i'm running two wsgi processes for my wsgi application (via mod_wsgi). invalid result is always returned by first of them and valid result is always returned by the second (until i restart wsgi app). this is why every second request gets crazy (there's a 50% chance). now why is this happening ? some kind of desynchronization between processes ?
>>>
>>
>>ah, now it makes more sense. i'm not familiar with mod_wsgi, but i don't
>>think mod_wsgi processes share information one way or the other. are you
>>sure both initialize correctly?
>>
>>why not use twisted, cherrypy or any other pure-python http solution and
>>use apache as a reverse-proxy?
>>
>>burak
>>
>>> ______________________________________________________________
>>>> Od: "azurIt" <azurit at pobox.sk>
>>>> Komu: <soap at python.org>
>>>> Dátum: 06.12.2011 18:43
>>>> Predmet: Re: [Soap-Python] rpclib - very strange problem
>>>>
>>>> cool, it's working now. problem is that traceback for both cases (where result is ok and is not ok) looks the same:
>>>>
>>>>
>>>> File "/usr/lib/python2.5/site-packages/rpclib-2.4.1_beta-py2.5.egg/rpclib/server/wsgi.py", line 168, in __call__
>>>>  return self.__handle_rpc(req_env, start_response)
>>>> File "/usr/lib/python2.5/site-packages/rpclib-2.4.1_beta-py2.5.egg/rpclib/server/wsgi.py", line 239, in __handle_rpc
>>>>  self.get_out_object(ctx)
>>>> File "/usr/lib/python2.5/site-packages/rpclib-2.4.1_beta-py2.5.egg/rpclib/server/_base.py", line 73, in get_out_object
>>>>  self.app.process_request(ctx)
>>>> File "/usr/lib/python2.5/site-packages/rpclib-2.4.1_beta-py2.5.egg/rpclib/application.py", line 102, in process_request
>>>>  ctx.out_object = self.call_wrapper(ctx)
>>>> File "/usr/lib/python2.5/site-packages/rpclib-2.4.1_beta-py2.5.egg/rpclib/_base.py", line 190, in __setattr__
>>>>  object.__setattr__(self, k, v)
>>>> File "/usr/lib/python2.5/site-packages/rpclib-2.4.1_beta-py2.5.egg/rpclib/_base.py", line 51, in set_out_object
>>>>  traceback.print_stack()
>>>>
>>>>
>>>> i can only see rpclib code, not mine. any hints how can i show something more ? thnx!!!
>>>>
>>>> azur
>>>>
>>>>
>>>> ______________________________________________________________
>>>>> Od: "Burak Arslan" <burak.arslan at arskom.com.tr>
>>>>> Komu: azurIt <azurit at pobox.sk>
>>>>> Dátum: 06.12.2011 17:53
>>>>> Predmet: Re: [Soap-Python] rpclib - very strange problem
>>>>>
>>>>> CC: soap at python.org
>>>>> On 12/06/11 18:51, Burak Arslan wrote:
>>>>>> On 12/06/11 18:46, azurIt wrote:
>>>>>>> Sorry for bordering, i would write/fix it by myself but i don't fully understand your code. This is what it is doing now:
>>>>>> you should read about the property built-in.
>>>>>>
>>>>>>> Traceback (most recent call last):
>>>>>>>   File "/usr/lib/python2.5/site-packages/rpclib-2.4.1_beta-py2.5.egg/rpclib/application.py", line 102, in process_request
>>>>>>>     ctx.out_object = self.call_wrapper(ctx)
>>>>>>>   File "/usr/lib/python2.5/site-packages/rpclib-2.4.1_beta-py2.5.egg/rpclib/_base.py", line 191, in __setattr__
>>>>>>>     raise ValueError("use the udc member for storing arbitrary data "
>>>>>>> ValueError: use the udc member for storing arbitrary data in the method context
>>>>>> set self.frozen to false in the constructor's last line.
>>>>> or rather add self.__out_object=None to the ctor.
>>>>>
>>>>>> i'd forgotten about the __getattr__ in that class, you can modify that
>>>>>> as well if you understand better what that does.
>>>>>>
>>>>>> burak
>>>>>>> ______________________________________________________________
>>>>>>>> Od: "Burak Arslan" <burak.arslan at arskom.com.tr>
>>>>>>>> Komu: azurIt <azurit at pobox.sk>
>>>>>>>> Dátum: 06.12.2011 17:19
>>>>>>>> Predmet: Re: [Soap-Python] rpclib - very strange problem
>>>>>>>>
>>>>>>>> CC: soap at python.org
>>>>>>>> On 12/06/11 18:14, azurIt wrote:
>>>>>>>>> Burak,
>>>>>>>>>
>>>>>>>>> can you, please, help me with this a little more? Where exactly should i put that code? Into _base.py file? Thank you!
>>>>>>>>>
>>>>>>>>> azur
>>>>>>>> yes, in the MethodContext class, like so:
>>>>>>>>
>>>>>>>> class MethodContext(object):
>>>>>>>>    def get_out_object(self):
>>>>>>>>       return self.__out_object
>>>>>>>>
>>>>>>>>    def set_out_object(self, what):
>>>>>>>>       import traceback
>>>>>>>>       traceback.print_stack()
>>>>>>>>       self.__out_object = what
>>>>>>>>
>>>>>>>>    out_object = property(get_out_object, set_out_object)
>>>>>>>>
>>>>>>>>    # (...)
>>>>>>>>    # rest of the class definition
>>>>>>>>
>>>>>>>> hth,
>>>>>>>> burak
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> ______________________________________________________________
>>>>>>>>>> Od: "Burak Arslan" <burak.arslan at arskom.com.tr>
>>>>>>>>>> Komu: azurIt <azurit at pobox.sk>
>>>>>>>>>> Dátum: 05.12.2011 18:33
>>>>>>>>>> Predmet: Re: [Soap-Python] rpclib - very strange problem
>>>>>>>>>>
>>>>>>>>>> CC: soap at python.org
>>>>>>>>>> On 12/05/11 17:55, azurIt wrote:
>>>>>>>>>>> Any hints ? :)
>>>>>>>>>> patch rpclib code to instrument the out_object attribute. have the
>>>>>>>>>> instrumentation spit tracebacks on assignments. that way you'll be able
>>>>>>>>>> to track where that strange value comes from.
>>>>>>>>>>
>>>>>>>>>> off the top of my head, add these to the MethodContext class:
>>>>>>>>>>
>>>>>>>>>> def get_out_object(self):
>>>>>>>>>>    return self.__out_object
>>>>>>>>>>
>>>>>>>>>> def set_out_object(self, what):
>>>>>>>>>>    import traceback
>>>>>>>>>>    traceback.print_stack()
>>>>>>>>>>    self.__out_object = what
>>>>>>>>>>
>>>>>>>>>> out_object = property(get_out_object, set_out_object)
>>>>>>>>>>
>>>>>>>>>> every _second_ request? heh, that's fun :)
>>>>>>>>>>
>>>>>>>>>> good luck,
>>>>>>>>>> burak
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> azur
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> Soap mailing list
>>>>>>>>>>> Soap at python.org
>>>>>>>>>>> http://mail.python.org/mailman/listinfo/soap
>>>>>>>>> _______________________________________________
>>>>>>>>> Soap mailing list
>>>>>>>>> Soap at python.org
>>>>>>>>> http://mail.python.org/mailman/listinfo/soap
>>>>>>> _______________________________________________
>>>>>>> Soap mailing list
>>>>>>> Soap at python.org
>>>>>>> http://mail.python.org/mailman/listinfo/soap
>>>>>> _______________________________________________
>>>>>> Soap mailing list
>>>>>> Soap at python.org
>>>>>> http://mail.python.org/mailman/listinfo/soap
>>>>>
>>>> _______________________________________________
>>>> Soap mailing list
>>>> Soap at python.org
>>>> http://mail.python.org/mailman/listinfo/soap
>>>>
>>> _______________________________________________
>>> Soap mailing list
>>> Soap at python.org
>>> http://mail.python.org/mailman/listinfo/soap
>>
>>
>_______________________________________________
>Soap mailing list
>Soap at python.org
>http://mail.python.org/mailman/listinfo/soap
>


More information about the Soap mailing list