I am using twisted and python to send some large text file over network, I would like to use UDP and multicast, What solution would be the best to do it, I need sample code cause I am already confused, When I try to do it I get error 24 from python which says too many open files, could you help me to resolve this issue?
here is part of my code:
if (options.upt != None):
print "UPGRADE is initiating"
sourceFile = open(options.upt, "r")
reactor.listenMulticast(1888, UpgradeReciever("Control Listener"), listenMultiple=True)
#with open(options.upt) as sourceFile:
for line in sourceFile:
upgradeSenderObj = UpgradeSender(line, "224.0.0.8", 1888)
reactor.listenMulticast(1888, upgradeSenderObj, listenMultiple=True)
reactor.run()
I have also tried to read the whole file and put in list and then call each element of list (which are in fact lines of my file) by twisted, but still got the similar problem, here is my updated code:
if (options.upt != None):
print "UPGRADE is initiating"
sourceFile = open(options.upt, "r")
reactor.listenMulticast(1888, UpgradeReciever("Control Listener"), listenMultiple=True)
dataContainer = list(sourceFile)
print dataContainer
for i in range(len(dataContainer)):
upgradeSenderObj = UpgradeSender(dataContainer[i], "224.0.0.8", 1888)
reactor.listenMulticast(1888, upgradeSenderObj, listenMultiple=True)
reactor.run()