task2.py
50 lines
| 924 B
| text/x-python
|
PythonLexer
Brian E Granger
|
r1337 | #!/usr/bin/env python | ||
# encoding: utf-8 | ||||
MinRK
|
r3690 | from IPython.parallel import Client | ||
Brian E Granger
|
r1337 | import time | ||
Fernando Perez
|
r2084 | import sys | ||
flush = sys.stdout.flush | ||||
Brian E Granger
|
r1337 | |||
MinRK
|
r3690 | rc = Client() | ||
v = rc.load_balanced_view() | ||||
mux = rc[:] | ||||
Brian E Granger
|
r1337 | |||
for i in range(24): | ||||
MinRK
|
r3690 | v.apply(time.sleep, 1) | ||
Brian E Granger
|
r1337 | |||
for i in range(6): | ||||
time.sleep(1.0) | ||||
Thomas Kluyver
|
r6455 | print("Queue status (vebose=False)") | ||
print(v.queue_status(verbose=False)) | ||||
Fernando Perez
|
r2084 | flush() | ||
Brian E Granger
|
r1337 | |||
for i in range(24): | ||||
MinRK
|
r3690 | v.apply(time.sleep, 1) | ||
Brian E Granger
|
r1337 | |||
for i in range(6): | ||||
time.sleep(1.0) | ||||
Thomas Kluyver
|
r6455 | print("Queue status (vebose=True)") | ||
print(v.queue_status(verbose=True)) | ||||
Fernando Perez
|
r2084 | flush() | ||
Brian E Granger
|
r1337 | |||
for i in range(12): | ||||
MinRK
|
r3690 | v.apply(time.sleep, 2) | ||
Brian E Granger
|
r1337 | |||
Thomas Kluyver
|
r6455 | print("Queue status (vebose=True)") | ||
print(v.queue_status(verbose=True)) | ||||
Fernando Perez
|
r2084 | flush() | ||
Brian E Granger
|
r1337 | |||
MinRK
|
r3690 | # qs = v.queue_status(verbose=True) | ||
# queued = qs['scheduled'] | ||||
Brian E Granger
|
r1337 | |||
MinRK
|
r3690 | for msg_id in v.history[-4:]: | ||
v.abort(msg_id) | ||||
Brian E Granger
|
r1337 | |||
for i in range(6): | ||||
time.sleep(1.0) | ||||
Thomas Kluyver
|
r6455 | print("Queue status (vebose=True)") | ||
print(v.queue_status(verbose=True)) | ||||
Fernando Perez
|
r2084 | flush() | ||
Brian E Granger
|
r1337 | |||