Re: serializers: how to upgrade
Irmen de Jong <[email protected]>
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <[email protected]> |
On 27-8-2013 8:21, Radim Rehurek wrote:
> Hello Irmen,
>
> there have been reports that Pyro stopped working on the gensim mailing
> list: https://groups.google.com/forum/#!topic/gensim/eXNEDxyQnwU
>
> I had a look and it seems to be related to the recent changes in serialization.
> Downgrading to 4.18 solves the problems.
Yep, this is expected behavior when your code relies on pickle to serialize custom types.
> What is the recommended way to do a backward-compatible upgrade? Following the
> documentation, I tried to set PYRO_SERIALIZER=pickle before starting any pyro4
> processes, but that just results in
[...]
> ProtocolError: message used serializer that is not accepted: 4
You've only changed the client part, you also need to tell Pyro to accept pickle as
incoming serialization format in the daemon.
I understand it may be a bit confusing so I've added the following paragraph to the
documentation:
*Upgrading older code that relies on pickle*
What do you have to do with code that relies on pickle, and worked fine in older Pyro
versions, but now crashes?
You can redesign the remote interface to only include types that can be serialized
(python’s built-in types and exception classes, and a few Pyro specific classes such as
URIs). That way you benefit from the new security that the alternative serializers
provide. If you can’t do this, you have to tell Pyro to enable pickle again. This has
been made an explicit step because of the security implications of using pickle. Here’s
how to do this:
Client code configuration:
Tell Pyro to use pickle as serializer for outgoing communication, by setting the
SERIALIZER config item to pickle. For instance, in your code: Pyro4.config.SERIALIZER =
'pickle' or set the appropriate environment variable.
Server code configuration:
Tell Pyro to accept pickle as incoming serialization format, by including pickle in the
SERIALIZERS_ACCEPTED config item list. For instance, in your code:
Pyro4.config.SERIALIZERS_ACCEPTED.add('pickle'). Or set the appropriate environment
variable, for instance: export PYRO_SERIALIZERS_ACCEPTED=serpent,json,marshal,pickle. If
your server also uses Pyro to call other servers, you may also need to configure it as
mentioned above at ‘client code’. This is because the incoming and outgoing serializer
formats are configured independently. To see how this works in practice you can look at
the stockquotes example.
Hope this helps,
Irmen
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk