mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
mmap examples
This commit is contained in:
parent
cf53928f90
commit
908e6e427c
2 changed files with 21 additions and 0 deletions
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…
Add table
Add a link
Reference in a new issue