-
Notifications
You must be signed in to change notification settings - Fork 175
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
feat: support keyboard interrupt in Python #1438
Conversation
def test_keyboard_interrupt(tmp_path, dataset): | ||
assert not dataset.has_index | ||
ann_ds = lance.write_dataset(dataset.to_table(), tmp_path / "indexed.lance") | ||
|
||
try: | ||
start_time = time.monotonic() | ||
|
||
# Create an index in a thread | ||
thread = Thread(target=ann_ds.create_index, args=("vector"), kwargs=dict( | ||
index_type="IVF_PQ", | ||
num_partitions=4, | ||
num_sub_vectors=16, | ||
)) | ||
|
||
raise KeyboardInterrupt() | ||
except KeyboardInterrupt: | ||
end_time = time.monotonic() | ||
|
||
assert end_time - start_time < 0.2 |
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.
Instead of testing at this level you could potentially write a unit test in executor.rs
that takes an endless dummy task (async sleep in a loop) and then make sure you can interrupt it.
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.
Eh I give up on testing this for now. I've confirmed manually this allows keyboard interrupt, and is especially handy for the create index part.
e27c347
to
ff8749c
Compare
Closes #1436.