mmap examples
This commit is contained in:
parent
cf53928f90
commit
908e6e427c
12
sandbox/mmap_client.py
Executable file
12
sandbox/mmap_client.py
Executable 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
9
sandbox/mmap_server.py
Executable 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()
|
||||||
Loading…
x
Reference in New Issue
Block a user