]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - www/pages/torrent/client/piecebuffer.py
1 # Written by John Hoffman
2 # see LICENSE.txt for license information
4 from array
import array
5 from threading
import Lock
16 def __init__(self
, pool
):
24 for x in xrange(6,1,-1):
26 f = inspect.currentframe(x).f_code
27 print (f.co_filename,f.co_firstlineno,f.co_name)
36 l
= self
.length
+len(s
)
37 self
.buf
[self
.length
:l
] = array('c',s
)
43 def __getslice__(self
, a
, b
):
48 if a
== 0 and b
== self
.length
and len(self
.buf
) == b
:
49 return self
.buf
# optimization
53 return self
.buf
[:self
.length
]
58 self
.pool
.release(self
)
73 x
= SingleBuffer(self
)
86 PieceBuffer
= _pool
.new