Skip to content
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

Add ability to interrupt other threads #468

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wmanley
Copy link
Contributor

@wmanley wmanley commented Nov 6, 2017

As long as they are blocked on stbt.frames() or time.sleep()

We add the ability to interrupt a thread that we've previously spawned - as long as they are blocked on get_frame or time.sleep. This takes care of tearing threads down once we're done with them without requiring the user to add any complicated logic for this purpose. This is the invasive part that requires changes to _stbt.core

This same mechanism could be used to implement a timeout contextmanager.

Example:

def look_for_logo():
    return wait_until(lambda: match("logo.png"))

t = threading.Thread(target=look_for_logo)
t.start()

interrupt(t)
t.join()

Notes

TODO

@wmanley wmanley mentioned this pull request Nov 6, 2017
4 tasks
@drothlis drothlis added this to the v28 milestone Nov 16, 2017
@drothlis
Copy link
Contributor

drothlis commented Jan 9, 2018

Rebased onto master to get Travis fixes from #474.

As long as they are blocked on `stbt.frames()` or `time.sleep()`

We add the ability to interrupt a thread that we've previously spawned -
as long as they are blocked on `get_frame` or `time.sleep`.  This takes
care of tearing threads down once we're done with them without requiring
the user to add any complicated logic for this purpose.  This is the
invasive part that requires changes to `_stbt.core`

This same mechanism could be used to implement a timeout `contextmanager`.

Example:

    def look_for_logo():
        return wait_until(lambda: match("logo.png"))

    t = threading.Thread(target=look_for_logo)
    t.start()

    interrupt(t)
    t.join()
@drothlis
Copy link
Contributor

drothlis commented Jan 9, 2018

Somehow this breaks test_press_visualisation consistently, both on Travis and my laptop.

@drothlis drothlis removed this from the v28 milestone Jan 18, 2018
@wmanley
Copy link
Contributor Author

wmanley commented Apr 11, 2018

See also: Timeouts and cancellation for humans

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants