comparison web/atomicfile.py @ 586:87c20b8c5472 default master

port to python3
author Matt Johnston <matt@ucc.asn.au>
date Mon, 09 Sep 2019 22:24:10 +0800
parents 6dd157a12035
children
comparison
equal deleted inserted replaced
585:1c484dab4e83 586:87c20b8c5472
21 21
22 os.ftruncate(f.fileno(), 0) 22 os.ftruncate(f.fileno(), 0)
23 f.write(data) 23 f.write(data)
24 return True 24 return True
25 25
26 except IOError, e: 26 except IOError as e:
27 print>>sys.stderr, e 27 print(e, file=sys.stderr)
28 28
29 return False 29 return False
30 30
31 def read(self, timeout = 5): 31 def read(self, timeout = 5):
32 try: 32 try:
39 time.sleep(DELAY) 39 time.sleep(DELAY)
40 continue 40 continue
41 41
42 return f.read() 42 return f.read()
43 43
44 except IOError, e: 44 except IOError as e:
45 print>>sys.stderr, e 45 print(e, file=sys.stderr)
46 46
47 return None 47 return None