I got this simple xmlrpc server script written in python. I limited the memory to 512mb to simulate the environment where the script will be running.
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 send a file of 20mb, i get the following exception:
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.MemoryError'>:">
Why can't i send a 10mb file to a server which has 512mb of memory?