Move slowpipe to tools and make it cleaner
This commit is contained in:
parent
e4d8341c9a
commit
8d3b04666f
@ -640,15 +640,7 @@ class Nodes(object):
|
|||||||
speed = int(speed * 0.9 / maxthreads)
|
speed = int(speed * 0.9 / maxthreads)
|
||||||
else:
|
else:
|
||||||
speed = int(speed * 0.9 / len(self.nodes))
|
speed = int(speed * 0.9 / len(self.nodes))
|
||||||
pythonslowpipe = 'import sys\n'
|
pythonslowpipe = slowpipe % speed
|
||||||
pythonslowpipe += 'import time\n'
|
|
||||||
pythonslowpipe += 'while 1:\n'
|
|
||||||
pythonslowpipe += ' a = sys.stdin.read(int(1250*%s))\n' % speed
|
|
||||||
pythonslowpipe += ' if a:\n'
|
|
||||||
pythonslowpipe += ' sys.stdout.write(a)\n'
|
|
||||||
pythonslowpipe += ' time.sleep(0.01)\n'
|
|
||||||
pythonslowpipe += ' else:\n'
|
|
||||||
pythonslowpipe += ' break\n'
|
|
||||||
semaphore = multiprocessing.BoundedSemaphore(maxthreads)
|
semaphore = multiprocessing.BoundedSemaphore(maxthreads)
|
||||||
for node in self.nodes.values():
|
for node in self.nodes.values():
|
||||||
if (self.cluster and str(self.cluster) != str(node.cluster) and
|
if (self.cluster and str(self.cluster) != str(node.cluster) and
|
||||||
|
@ -27,6 +27,19 @@ import multiprocessing
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
slowpipe = '''
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
while 1:
|
||||||
|
a = sys.stdin.read(int(1250*%s))
|
||||||
|
if a:
|
||||||
|
sys.stdout.write(a)
|
||||||
|
time.sleep(0.01)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
def interrupt_wrapper(f):
|
def interrupt_wrapper(f):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user