-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove control queue #1210
Remove control queue #1210
Changes from all commits
12e3fd7
5d11167
4abf5af
6447b2e
6d69f30
284d4a2
ba7c252
86b2f26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
import subprocess | ||
import sys | ||
import time | ||
from datetime import datetime, timedelta | ||
from subprocess import Popen | ||
from tempfile import TemporaryDirectory | ||
|
||
|
@@ -597,6 +598,47 @@ def test_control_thread_priority(): | |
assert control_dates[-1] <= shell_dates[0] | ||
|
||
|
||
def test_sequential_control_messages(): | ||
with new_kernel() as kc: | ||
msg_id = kc.execute("import time") | ||
get_reply(kc, msg_id) | ||
|
||
# Send multiple messages on the control channel. | ||
# Using execute messages to vary duration. | ||
sleeps = [0.6, 0.3, 0.1] | ||
|
||
# Prepare messages | ||
msgs = [ | ||
kc.session.msg("execute_request", {"code": f"time.sleep({sleep})"}) for sleep in sleeps | ||
] | ||
msg_ids = [msg["header"]["msg_id"] for msg in msgs] | ||
|
||
# Submit messages | ||
for msg in msgs: | ||
kc.control_channel.send(msg) | ||
|
||
# Get replies | ||
replies = [get_reply(kc, msg_id, channel="control") for msg_id in msg_ids] | ||
|
||
# Check messages are processed in order, one at a time, and of a sensible duration. | ||
previous_end = None | ||
for reply, sleep in zip(replies, sleeps): | ||
start_str = reply["metadata"]["started"] | ||
if sys.version_info[:2] < (3, 11) and start_str.endswith("Z"): | ||
# Python < 3.11 doesn't support "Z" suffix in datetime.fromisoformat, | ||
# so use alternative timezone format. | ||
# https://github.com/python/cpython/issues/80010 | ||
start_str = start_str[:-1] + "+00:00" | ||
start = datetime.fromisoformat(start_str) | ||
end = reply["header"]["date"] # Already a datetime | ||
|
||
if previous_end is not None: | ||
assert start > previous_end | ||
previous_end = end | ||
|
||
assert end >= start + timedelta(seconds=sleep) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fails downstream in IPython with: TypeError: '>=' not supported between instances of 'str' and 'datetime.datetime' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are the same symptoms that I observed at #1210 (comment). In this PR updating I think the sensible approach here is to assume that in this test sometimes, outside of our direct control, the dates are strings and convert them to datetimes. Otherwise this test is not testing what it is supposed to, it is testing the types of some fields returned in messages. I'll submit a PR here ASAP. |
||
|
||
|
||
def _child(): | ||
print("in child", os.getpid()) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is blocking for 1ms, right? I think it should just check if there is a message:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to, but if I do that the
ipyparallel
tests fail locally for me.