sending executable data over network..
exarkun at divmod.com
Wed Jun 25 17:48:56 CEST 2008
On Wed, 25 Jun 2008 10:28:10 -0500, Larry Bates <larry.bates at websafe.com`> wrote:
>Cédric Lucantis wrote:
>>Le Tuesday 24 June 2008 08:59:40 Piyush Anonymous, vous avez écrit :
>>>i wish to change the way the function definition at run time in a running
>>>server. new function code which is to be executed is provided by a client
>>>at different location.
>>>i am getting it by reading a file and sending it using makefile() with
>>>server/client connected using sockets.
>>>how can make the lines received in a string array as new function
>>>definition? or should i receive it in a different way?
>>>is there any better way to do the entire thing?
>>One way is to transmit the code as a string and compile it on server-side
>>with the 'compile' builtin function. Another is to compile it on client-
>>side and transmit the resulting code object with the marshal module but
>>there are many restrictions on it (specially the fact that the client and
>>server will have to run the same python version) so carefully read the docs
>>first. I'd choose the first solution, eventually using the pickle module to
>>avoid encoding problems.
>You may want to take a look at Twisted Python Perspective Broker. I believe
>it does what you are looking for.
Twisted PB goes out of its way to *not* allow arbitrary code specified by
a peer to be executed, actually. :) It is intended to be used when you
cannot trust the network (a common scenario) but still want to perform
complex operations and pass complex data around.
More information about the Python-list