Why is a DirectView.execute() never ready() in ipyparallel and how can I purge?
I have an ipyparallel
job that takes up too much memory because results are large, so I am modifying it to use Client.purge_local_results() and purge_hub_results()
. If I am using dview.execute()
as recommended, I end up with an AsyncResult
and can successfully run other code blocks in the load-balanced view, but the original result never is ready()
.
Furthermore, the message_ids from the original result remain in Client.outstanding
which prevents the purge()
commands from succeeding. Using block=True
and block=False
both give unexpected behavior.
Below is example code. This is using Python version 3.6.7, ipyparallel version 6.2.2 on CentOS7.
import sys
import time
import ipyparallel
print("Python version {}, ipyparallel version {}".format(sys.version, ipyparallel.__version__))
cluster_profile = sys.argv[1]
try:
rc = ipyparallel.Client(profile=cluster_profile)
except (ipyparallel.error.TimeoutError, OSError):
print("The cluster request for '{}' timed out. Is it defined and running?".format(cluster_profile))
exit(2)
dview = rc[:]
lview = rc.load_balanced_view()
def trivial_fn(x=None):
import os
pid = os.getpid()
filename = '/tmp/{}.pid'.format(pid)
with open(filename, 'a'):
os.utime(filename)
return str(pid) + str(datetime.datetime.now())
if sys.argv[2] == 'block':
print("Running with block=True..... (Use Ctrl-C if this hangs).")
async_exec_withblock = dview.execute('trivial_fn()', block=True)
# Note, this does hang until pressing Ctrl-C
print("Blocking OK, got {}. ".format(async_exec_withblock))
# Note, we never get to the following line. A second Ctrl-C kills us
print("Blocking Done, got {}n:{} ".format(async_exec_withblock, list(async_exec_withblock) ) )
print("Finished.")
exit(0)
else:
print("Running with block=False.... (Use Ctrl-C if this hangs)")
async_exec_noblock = dview.execute('import datetime', block=False)
print("Nonblocking request done, got class {}: {}. Running a map_async() on the load balanced view.....".format(
async_exec_noblock.__class__, str(async_exec_noblock)
))
mapped_trivial = lview.map_async(trivial_fn, list(range(4)))
# Note, this successfully prints expected results from the load-balanced view
print('Load balanced view returned {}'.format(' '.join(mapped_trivial)))
print('Now waiting for ready() from old non-blocking request....')
while not async_exec_noblock.ready():
time.sleep(0.5)
print('Still waiting. Current Client.outstanding size is {}....'.format(len(rc.outstanding)))
# Note, this repeats forever
# Note, we never get to the following line...
print("Non-blocking OK, got {}. ".format(list(async_exec_noblock)))
print("Finished.")
exit(0)
python python-3.x parallel-processing ipython-parallel
add a comment |
I have an ipyparallel
job that takes up too much memory because results are large, so I am modifying it to use Client.purge_local_results() and purge_hub_results()
. If I am using dview.execute()
as recommended, I end up with an AsyncResult
and can successfully run other code blocks in the load-balanced view, but the original result never is ready()
.
Furthermore, the message_ids from the original result remain in Client.outstanding
which prevents the purge()
commands from succeeding. Using block=True
and block=False
both give unexpected behavior.
Below is example code. This is using Python version 3.6.7, ipyparallel version 6.2.2 on CentOS7.
import sys
import time
import ipyparallel
print("Python version {}, ipyparallel version {}".format(sys.version, ipyparallel.__version__))
cluster_profile = sys.argv[1]
try:
rc = ipyparallel.Client(profile=cluster_profile)
except (ipyparallel.error.TimeoutError, OSError):
print("The cluster request for '{}' timed out. Is it defined and running?".format(cluster_profile))
exit(2)
dview = rc[:]
lview = rc.load_balanced_view()
def trivial_fn(x=None):
import os
pid = os.getpid()
filename = '/tmp/{}.pid'.format(pid)
with open(filename, 'a'):
os.utime(filename)
return str(pid) + str(datetime.datetime.now())
if sys.argv[2] == 'block':
print("Running with block=True..... (Use Ctrl-C if this hangs).")
async_exec_withblock = dview.execute('trivial_fn()', block=True)
# Note, this does hang until pressing Ctrl-C
print("Blocking OK, got {}. ".format(async_exec_withblock))
# Note, we never get to the following line. A second Ctrl-C kills us
print("Blocking Done, got {}n:{} ".format(async_exec_withblock, list(async_exec_withblock) ) )
print("Finished.")
exit(0)
else:
print("Running with block=False.... (Use Ctrl-C if this hangs)")
async_exec_noblock = dview.execute('import datetime', block=False)
print("Nonblocking request done, got class {}: {}. Running a map_async() on the load balanced view.....".format(
async_exec_noblock.__class__, str(async_exec_noblock)
))
mapped_trivial = lview.map_async(trivial_fn, list(range(4)))
# Note, this successfully prints expected results from the load-balanced view
print('Load balanced view returned {}'.format(' '.join(mapped_trivial)))
print('Now waiting for ready() from old non-blocking request....')
while not async_exec_noblock.ready():
time.sleep(0.5)
print('Still waiting. Current Client.outstanding size is {}....'.format(len(rc.outstanding)))
# Note, this repeats forever
# Note, we never get to the following line...
print("Non-blocking OK, got {}. ".format(list(async_exec_noblock)))
print("Finished.")
exit(0)
python python-3.x parallel-processing ipython-parallel
add a comment |
I have an ipyparallel
job that takes up too much memory because results are large, so I am modifying it to use Client.purge_local_results() and purge_hub_results()
. If I am using dview.execute()
as recommended, I end up with an AsyncResult
and can successfully run other code blocks in the load-balanced view, but the original result never is ready()
.
Furthermore, the message_ids from the original result remain in Client.outstanding
which prevents the purge()
commands from succeeding. Using block=True
and block=False
both give unexpected behavior.
Below is example code. This is using Python version 3.6.7, ipyparallel version 6.2.2 on CentOS7.
import sys
import time
import ipyparallel
print("Python version {}, ipyparallel version {}".format(sys.version, ipyparallel.__version__))
cluster_profile = sys.argv[1]
try:
rc = ipyparallel.Client(profile=cluster_profile)
except (ipyparallel.error.TimeoutError, OSError):
print("The cluster request for '{}' timed out. Is it defined and running?".format(cluster_profile))
exit(2)
dview = rc[:]
lview = rc.load_balanced_view()
def trivial_fn(x=None):
import os
pid = os.getpid()
filename = '/tmp/{}.pid'.format(pid)
with open(filename, 'a'):
os.utime(filename)
return str(pid) + str(datetime.datetime.now())
if sys.argv[2] == 'block':
print("Running with block=True..... (Use Ctrl-C if this hangs).")
async_exec_withblock = dview.execute('trivial_fn()', block=True)
# Note, this does hang until pressing Ctrl-C
print("Blocking OK, got {}. ".format(async_exec_withblock))
# Note, we never get to the following line. A second Ctrl-C kills us
print("Blocking Done, got {}n:{} ".format(async_exec_withblock, list(async_exec_withblock) ) )
print("Finished.")
exit(0)
else:
print("Running with block=False.... (Use Ctrl-C if this hangs)")
async_exec_noblock = dview.execute('import datetime', block=False)
print("Nonblocking request done, got class {}: {}. Running a map_async() on the load balanced view.....".format(
async_exec_noblock.__class__, str(async_exec_noblock)
))
mapped_trivial = lview.map_async(trivial_fn, list(range(4)))
# Note, this successfully prints expected results from the load-balanced view
print('Load balanced view returned {}'.format(' '.join(mapped_trivial)))
print('Now waiting for ready() from old non-blocking request....')
while not async_exec_noblock.ready():
time.sleep(0.5)
print('Still waiting. Current Client.outstanding size is {}....'.format(len(rc.outstanding)))
# Note, this repeats forever
# Note, we never get to the following line...
print("Non-blocking OK, got {}. ".format(list(async_exec_noblock)))
print("Finished.")
exit(0)
python python-3.x parallel-processing ipython-parallel
I have an ipyparallel
job that takes up too much memory because results are large, so I am modifying it to use Client.purge_local_results() and purge_hub_results()
. If I am using dview.execute()
as recommended, I end up with an AsyncResult
and can successfully run other code blocks in the load-balanced view, but the original result never is ready()
.
Furthermore, the message_ids from the original result remain in Client.outstanding
which prevents the purge()
commands from succeeding. Using block=True
and block=False
both give unexpected behavior.
Below is example code. This is using Python version 3.6.7, ipyparallel version 6.2.2 on CentOS7.
import sys
import time
import ipyparallel
print("Python version {}, ipyparallel version {}".format(sys.version, ipyparallel.__version__))
cluster_profile = sys.argv[1]
try:
rc = ipyparallel.Client(profile=cluster_profile)
except (ipyparallel.error.TimeoutError, OSError):
print("The cluster request for '{}' timed out. Is it defined and running?".format(cluster_profile))
exit(2)
dview = rc[:]
lview = rc.load_balanced_view()
def trivial_fn(x=None):
import os
pid = os.getpid()
filename = '/tmp/{}.pid'.format(pid)
with open(filename, 'a'):
os.utime(filename)
return str(pid) + str(datetime.datetime.now())
if sys.argv[2] == 'block':
print("Running with block=True..... (Use Ctrl-C if this hangs).")
async_exec_withblock = dview.execute('trivial_fn()', block=True)
# Note, this does hang until pressing Ctrl-C
print("Blocking OK, got {}. ".format(async_exec_withblock))
# Note, we never get to the following line. A second Ctrl-C kills us
print("Blocking Done, got {}n:{} ".format(async_exec_withblock, list(async_exec_withblock) ) )
print("Finished.")
exit(0)
else:
print("Running with block=False.... (Use Ctrl-C if this hangs)")
async_exec_noblock = dview.execute('import datetime', block=False)
print("Nonblocking request done, got class {}: {}. Running a map_async() on the load balanced view.....".format(
async_exec_noblock.__class__, str(async_exec_noblock)
))
mapped_trivial = lview.map_async(trivial_fn, list(range(4)))
# Note, this successfully prints expected results from the load-balanced view
print('Load balanced view returned {}'.format(' '.join(mapped_trivial)))
print('Now waiting for ready() from old non-blocking request....')
while not async_exec_noblock.ready():
time.sleep(0.5)
print('Still waiting. Current Client.outstanding size is {}....'.format(len(rc.outstanding)))
# Note, this repeats forever
# Note, we never get to the following line...
print("Non-blocking OK, got {}. ".format(list(async_exec_noblock)))
print("Finished.")
exit(0)
python python-3.x parallel-processing ipython-parallel
python python-3.x parallel-processing ipython-parallel
edited Nov 28 '18 at 21:23
Brian B
asked Nov 28 '18 at 21:01
Brian BBrian B
8151124
8151124
add a comment |
add a comment |
0
active
oldest
votes
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53528031%2fwhy-is-a-directview-execute-never-ready-in-ipyparallel-and-how-can-i-purge%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53528031%2fwhy-is-a-directview-execute-never-ready-in-ipyparallel-and-how-can-i-purge%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown