Skip to content

Commit e989b8d

Browse files
committed
Strip trailing whitespace
1 parent 5422b54 commit e989b8d

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

nonblock/BackgroundRead.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
read.py Contains pure-python functions for non-blocking reads in python
55
6-
6+
77
'''
88
# vim: ts=4 sw=4 expandtab
99

@@ -27,7 +27,7 @@ def bgread(stream, blockSizeLimit=65535, pollTime=.03, closeStream=True):
2727
If None, the stream will be read from until there is no more available data (not closed, but you've read all that's been flushed to straem). This is okay for smaller datasets, but this number effectively controls the amount of CPU time spent in I/O on this stream VS everything else in your application. The default of 65535 bytes is a fair amount of data.
2828
2929
@param pollTime <float> - Default .03 (30ms) After all available data has been read from the stream, wait this many seconds before checking again for more data.
30-
30+
3131
A low number here means a high priority, i.e. more cycles will be devoted to checking and collecting the background data. Since this is a non-blocking read, this value is the "block", which will return execution context to the remainder of the application. The default of 100ms should be fine in most cases. If it's really idle data collection, you may want to try a value of 1 second.
3232
3333
@param closeStream <bool> - Default True. If True, the "close" method on the stream object will be called when the other side has closed and all data has been read.
@@ -84,7 +84,7 @@ class BackgroundReadData(object):
8484
data - A calculated property, which is a bytes/str (depending on stream mode). It is the joining of all the read blocks, and contains all the data read to-date.
8585
8686
isFinished - starts False, and becomes True after all data has been read from the stream. Will remain False if there is an exception raised during I/O
87-
87+
8888
error - starts None, and is set to any exception that is raised during reading (which will also terminate the thread)
8989
'''
9090

@@ -109,7 +109,7 @@ def data(self):
109109
'''
110110

111111
return self.emptyStr.join(self.blocks)
112-
112+
113113

114114

115115

nonblock/BackgroundWrite.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def bgwrite(fileObj, data, closeWhenFinished=False, chainAfter=None, ioPrio=4):
4646
4747
@return - BackgroundWriteProcess - An object representing the state of this operation. @see BackgroundWriteProcess
4848
'''
49-
49+
5050
thread = BackgroundWriteProcess(fileObj, data, closeWhenFinished, chainAfter, ioPrio)
5151
thread.start()
5252

@@ -82,7 +82,7 @@ class BackgroundIOPriority(object):
8282

8383
def __init__(self, chainPollTime, defaultChunkSize, bandwidthPct, numChunksRateSmoothing=5):
8484
'''
85-
__init__ - Create a BackgroundIOPriority.
85+
__init__ - Create a BackgroundIOPriority.
8686
8787
Some terms: throughput - Bandwidth out (Megs per second)
8888
interactivity - CPU time available for other tasks (calculations, other I/O, etc)
@@ -102,16 +102,16 @@ def __init__(self, chainPollTime, defaultChunkSize, bandwidthPct, numChunksRateS
102102
max bandwidth, i.e. the max rate of the I/O device, but the amount of available bandwidth available to this application. For example,
103103
if this is given "100%", no throttling is performed. If this is given "80%", then it calculates the average time to write a single chunk,
104104
( see #numChunksRateSmoothing for how many chunks are used in evaluating this average ), and sleeps for then 20% of that time at the end
105-
of every chunk.
105+
of every chunk.
106106
107107
@param numChunksRateSmoothing - integer >= 1 , Default 5. This is the number of chunks which are used in calculating the current throughput rate.
108108
See #bandwidthPct for the other half of the story. The higher this number, the more "fair" your application will be against a constant
109109
rate of I/O by other applications, but the less able it may be to play fair when the external I/O is spiking.
110110
111111
Also, consider that this is related to the #defaultChunkSize, as it is not a constant period of time. The default of "5" should be okay,
112112
but you may want to tune it if you use really large or really small chunk sizes.
113-
114-
113+
114+
115115
An "interactivity score" is defined to be (number of calculations) / (time to write data).
116116
'''
117117

@@ -133,7 +133,7 @@ def __setitem__(self, key, value):
133133
if key in BackgroundIOPriority.__slots__:
134134
return setattr(self, key, value)
135135
raise KeyError('Unknown key: %s\n' %(key,))
136-
136+
137137

138138
_SIZE_MEG = 1024 * 1024
139139

@@ -275,15 +275,15 @@ def run(self):
275275
shouldRecalculate = lambda i, numChunksRateSmoothing, firstPass : False
276276
else:
277277
shouldRecalculate = lambda i, numChunksRateSmoothing, firstPass : firstPass or i == numChunksRateSmoothing
278-
278+
279279

280280
while len(self.remainingData) > 0:
281281

282282
# pop, write, flush
283283
nextData = self.remainingData.popleft()
284284
fileObj.write(nextData)
285285
doFlush(fileObj)
286-
286+
287287
dataWritten += len(nextData)
288288
if sleepTime:
289289
sleepBefore = time.time()
@@ -292,9 +292,9 @@ def run(self):
292292

293293
sleepAfter = time.time()
294294
timeSlept += (sleepAfter - sleepBefore)
295-
295+
296296
if shouldRecalculate(i, numChunksRateSmoothing, firstPass) is True:
297-
# if not sleeptime, we are on first
297+
# if not sleeptime, we are on first
298298
# We've completed a full period, time for charity
299299
after = time.time()
300300

nonblock/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def detect_stream_mode(stream):
1818
elif 't' in stream.mode:
1919
return str
2020

21-
# Read a zero-length string off the device
21+
# Read a zero-length string off the device
2222
if hasattr(stream, 'read'):
2323
zeroStr = stream.read(0)
2424
if type(zeroStr) is str:

nonblock/read.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
read.py Contains pure-python functions for non-blocking reads in python
55
6-
6+
77
'''
88
# vim: ts=4 sw=4 expandtab
99

0 commit comments

Comments
 (0)