Use iterators for potentially large queries to reduce memory use
This commit is contained in:
parent
c1b42e0c67
commit
fde4e75da2
2 changed files with 97 additions and 41 deletions
|
|
@ -28,6 +28,7 @@ import traceback
|
|||
import types
|
||||
import pprint
|
||||
import resource
|
||||
import xmlrpclib
|
||||
from xmlrpclib import getparser,dumps,Fault
|
||||
from koji.server import WSGIWrapper
|
||||
|
||||
|
|
@ -40,6 +41,22 @@ import koji.util
|
|||
from koji.context import context
|
||||
|
||||
|
||||
# Workaround to allow xmlrpclib deal with iterators
|
||||
class Marshaller(xmlrpclib.Marshaller):
|
||||
|
||||
dispatch = xmlrpclib.Marshaller.dispatch.copy()
|
||||
|
||||
def dump_generator(self, value, write):
|
||||
dump = self.__dump
|
||||
write("<value><array><data>\n")
|
||||
for v in value:
|
||||
dump(v, write)
|
||||
write("</data></array></value>\n")
|
||||
dispatch[types.GeneratorType] = dump_generator
|
||||
|
||||
xmlrpclib.Marshaller = Marshaller
|
||||
|
||||
|
||||
class HandlerRegistry(object):
|
||||
"""Track handlers for RPC calls"""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue