469,890 Members | 1,607 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

Re: sending executable data over network..

Le Tuesday 24 June 2008 08:59:40 Piyush Anonymous, vous avez Ă©critÂ*:
hi,
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.

--
CĂ©dric Lucantis
Jun 27 '08 #1
1 1417
CĂ©dric Lucantis wrote:
Le Tuesday 24 June 2008 08:59:40 Piyush Anonymous, vous avez Ă©crit :
>hi,
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.

-Larry
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by klkuenzel | last post: by
7 posts views Thread by John Bailo | last post: by
4 posts views Thread by david | last post: by
17 posts views Thread by =?Utf-8?B?V2VuZHkgRWxpemFiZXRo?= | last post: by
reply views Thread by Jean-Paul Calderone | last post: by
1 post views Thread by Paulo | last post: by
2 posts views Thread by =?ISO-8859-1?B?RulybmFz?= | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.