Skip to content

Commit e663296

Browse files
authored
Merge pull request #119 from jacomago/chunk_cf
Chunk the calls to ChannelFinder
2 parents 71fab92 + 2fb0403 commit e663296

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

server/demo.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
# Uncomment line below to turn on the feature to add description field to channelfinder
8181
#recordDesc = True
8282

83-
# The size limit for finding channels (ie the value of the '~size' query parameter)
83+
# The size limit for finding channels and submitting channels
84+
# (ie the value of the '~size' query parameter)
8485
# If not specified then the fallback is the server default
8586
#findSizeLimit = 10000
8687

server/recceiver/cfstore.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,14 +709,20 @@ def __updateCF__(
709709
_log.debug("Add new alias: {s}".format(s=channels[-1]))
710710
_log.info("Total channels to update: {nChannels} {iocName}".format(nChannels=len(channels), iocName=iocName))
711711
if len(channels) != 0:
712-
client.set(channels=channels)
712+
cf_set_chunked(client, channels, conf.get("findSizeLimit", 10000))
713713
else:
714714
if old_channels and len(old_channels) != 0:
715-
client.set(channels=channels)
715+
cf_set_chunked(client, channels, conf.get("findSizeLimit", 10000))
716716
if processor.cancelled:
717717
raise defer.CancelledError()
718718

719719

720+
def cf_set_chunked(client, channels, chunk_size=10000):
721+
for i in range(0, len(channels), chunk_size):
722+
chunk = channels[i : i + chunk_size]
723+
client.set(channels=chunk)
724+
725+
720726
def create_properties(owner, iocTime, recceiverid, hostName, iocName, iocIP, iocid):
721727
return [
722728
create_property(owner, "hostName", hostName),

0 commit comments

Comments
 (0)