for i in xrange(1,NUM_USERS+1):
print i
private = RSA.generate(3072,Random.new().read)
public = private.publickey()
new_user = User(public_rsa=public.exportKey(), secret_rsa=private.exportKey())
new_user.save()
In the above loop, I have given the value of NUM_USERS=100
but the loop is iterating till 200 instead of 100. What might be the possible reason for this ?
EDIT: I am so sorry guys, I accidentally figured out that the whole python method is being called twice, I don't know why though, so I will describe in detail. I am writing a django based server side, which has methods as following:
def index(request):
return HttpResponse("CREST Top Dir: " + PROJECT_ROOT)
def server_setup(request):
try:
process = subprocess.check_output(BACKEND+"mainbgw setup " + str(NUM_USERS), shell=True,\
stderr=subprocess.STDOUT)
for i in xrange(1,NUM_USERS+1):
print i
Now what happens is when I call the server_setup
view sometimes it executes more than once. Similarly if I call index
view sometimes server_setup
is also called in simultaneously. So the problem is not with xrange
but with method calling. What could be the reason for this problem ?