mmap examples

This commit is contained in:
Zach Tibbitts 2006-12-06 03:51:33 +00:00
parent cf53928f90
commit 908e6e427c
2 changed files with 21 additions and 0 deletions

12
sandbox/mmap_client.py Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env python2.4
import mmap, os, time
mx = mmap.mmap(os.open('xxx',os.O_RDWR), 1)
last = None
while True:
mx.resize(mx.size())
data = mx[:]
if data != last:
print data
last = data
time.sleep(1)

9
sandbox/mmap_server.py Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env python2.4
fileob = open('xxx','w')
while True:
data = raw_input('Enter some text:')
fileob.seek(0)
fileob.write(data)
fileob.truncate()
fileob.flush()