comparison py/receive.py @ 196:e27075b1e088

Make sure we close descriptor before rename
author Matt Johnston <matt@ucc.asn.au>
date Wed, 12 Feb 2014 20:57:30 +0800
parents 063ff856f9c5
children 185621f47040
comparison
equal deleted inserted replaced
195:4f832e28ffc0 196:e27075b1e088
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())