Python: xmlrpc from memory when uploading binaries

I got this simple xmlrpc server script written in python. I have limited the memory to 512mb to simulate the environment the script will run in.

import SimpleXMLRPCServer
import resource

MEMORY_LIMIT = 512
resource.setrlimit(resource.RLIMIT_AS, (MEMORY_LIMIT * 1048576L, -1L))

class Functions:
  def foo(self, file):
    print "received file"

server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000))
server.allow_none = True
server.register_instance(Functions())
server.serve_forever()

      

Then I got this client script:

import xmlrpclib
import sys

client = xmlrpclib.Server('http://localhost:8000')

file = open(sys.argv[1], 'r')
binary = xmlrpclib.Binary(file.read())

client.foo(binary)

      

When I upload a file from 20mb, I get the following exception:

xmlrpclib.Fault: <Fault 1: "<type 'exceptions.MemoryError'>:">

      

Why can't I send a 10mb file to a server with 512MB of memory?

+3
python-2.7 memory xmlrpclib


source to share


No one has answered this question yet

Check out similar questions:

238
How can I explicitly free memory in Python?
4
How to pass binary data via xmlrpc (python)?
3
xmlrpc server problem
2
using getattr on python proxy xmlrpc
2
How to expose client_address for all methods using xmlrpclib?
1
Xmlrpclib and Python DOM Marshal
0
Is there a relationship between python open buffering and file.read options
0
decode binary from xmlrpc python
0
PHP Fatal error: Out of memory (allocated 1707606016) (tried to allocate 426680697 bytes)
0
How can I binary read a file in TCL and send it via XMLRPC to a server written in Python?



All Articles
Loading...
X
Show
Funny
Dev
Pics