comparison py/receive.py @ 495:905bbab632f7

Make sure we close descriptor before rename
author Matt Johnston <matt@ucc.asn.au>
date Wed, 12 Feb 2014 20:57:30 +0800
parents 20db270cc23a
children 185621f47040
comparison
equal deleted inserted replaced
494:1800a07f20e0 495:905bbab632f7
42 t = tempfile.NamedTemporaryFile(prefix='config', 42 t = tempfile.NamedTemporaryFile(prefix='config',
43 dir = dir, 43 dir = dir,
44 delete = False) 44 delete = False)
45 45
46 t.write(json.dumps(new_params, sort_keys=True, indent=4)+'\n') 46 t.write(json.dumps(new_params, sort_keys=True, indent=4)+'\n')
47 name = t.name
48 t.close()
47 49
48 os.rename(t.name, config.PARAMS_FILE) 50 os.rename(name, config.PARAMS_FILE)
49 except Exception, e: 51 except Exception, e:
50 return "Problem: %s" % e 52 return "Problem: %s" % e
51 53
52 try: 54 try:
53 pid = int(open('%s/tempserver.pid' % dir, 'r').read()) 55 pid = int(open('%s/tempserver.pid' % dir, 'r').read())