-
-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve cleaning up Inotify threads and add eventlet test cases.
- Loading branch information
1 parent
4e9a86d
commit 7bca6d9
Showing
7 changed files
with
149 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
if __name__ == '__main__': | ||
import eventlet | ||
|
||
eventlet.monkey_patch() | ||
|
||
import signal | ||
import sys | ||
import tempfile | ||
|
||
from watchdog.observers import Observer | ||
from watchdog.events import LoggingEventHandler | ||
|
||
with tempfile.TemporaryDirectory() as temp_dir: | ||
def run_observer(): | ||
event_handler = LoggingEventHandler() | ||
observer = Observer() | ||
observer.schedule(event_handler, temp_dir) | ||
observer.start() | ||
eventlet.sleep(1) | ||
observer.stop() | ||
|
||
def on_alarm(signum, frame): | ||
print("Observer.stop() never finished!", file=sys.stderr) | ||
sys.exit(1) | ||
|
||
signal.signal(signal.SIGALRM, on_alarm) | ||
signal.alarm(4) | ||
|
||
thread = eventlet.spawn(run_observer) | ||
thread.wait() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
if __name__ == '__main__': | ||
import eventlet | ||
|
||
eventlet.monkey_patch() | ||
|
||
from watchdog.utils.bricks import SkipRepeatsQueue | ||
|
||
# same as test_basic_queue() inside test_skip_repeats_queue.py | ||
|
||
q = SkipRepeatsQueue() | ||
|
||
e1 = (2, "fred") | ||
e2 = (2, "george") | ||
e3 = (4, "sally") | ||
|
||
q.put(e1) | ||
q.put(e2) | ||
q.put(e3) | ||
|
||
assert e1 == q.get() | ||
assert e2 == q.get() | ||
assert e3 == q.get() | ||
assert q.empty() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
import importlib | ||
|
||
from .markers import cpython_only | ||
from .utils import run_isolated_test | ||
|
||
|
||
@cpython_only | ||
def test_observer_stops_in_eventlet(): | ||
if not importlib.util.find_spec('eventlet'): | ||
pytest.skip("eventlet not installed") | ||
|
||
run_isolated_test('eventlet_observer_stops.py') | ||
|
||
|
||
@cpython_only | ||
def test_eventlet_skip_repeat_queue(): | ||
if not importlib.util.find_spec('eventlet'): | ||
pytest.skip("eventlet not installed") | ||
|
||
run_isolated_test('eventlet_skip_repeat_queue.py') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters