Commit 0398e23d authored by Kirill Smelkov's avatar Kirill Smelkov

X bytearray turned out to be copying data

-> use memoryview instead
parent 4283b91d
...@@ -115,7 +115,7 @@ def timeout(parent=context.background()): # -> ctx ...@@ -115,7 +115,7 @@ def timeout(parent=context.background()): # -> ctx
# XXX # XXX
def tdelay(): def tdelay():
time.sleep(10*time.millisecond) # XXX -> 1ms ? time.sleep(1*time.millisecond) # XXX -> 10ms ?
# ---- test join/autostart ---- # ---- test join/autostart ----
...@@ -401,10 +401,10 @@ class tFile: ...@@ -401,10 +401,10 @@ class tFile:
mm.unmap(t.fmmap) mm.unmap(t.fmmap)
t.f.close() t.f.close()
# blk returns bytearray view of file[blk]. # blk returns memoryview of file[blk].
def blk(t, blk): def blk(t, blk):
assert blk <= t._max_tracked assert blk <= t._max_tracked
return bytearray(t.fmmap[blk*t.blksize:(blk+1)*t.blksize]) return memoryview(t.fmmap[blk*t.blksize:(blk+1)*t.blksize])
# cached returns [] with indicating whether a file block is cached or not. # cached returns [] with indicating whether a file block is cached or not.
# 1 - cached, 0 - not cached, fractional (0,1) - some pages of the block are cached some not. # 1 - cached, 0 - not cached, fractional (0,1) - some pages of the block are cached some not.
...@@ -973,8 +973,10 @@ def test_wcfs(): ...@@ -973,8 +973,10 @@ def test_wcfs():
ev.append('pin ack') ev.append('pin ack')
pin.ack() pin.ack()
ev.append('read pre') assert f.cached()[2] == 0
blk = f.blk(2) blk = f.blk(2)
assert f.cached()[2] == 0
ev.append('read pre')
blk[0] # read access -> XXX without GIL blk[0] # read access -> XXX without GIL
ev.append('read post') ev.append('read post')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment