github
18 of 23 new or added lines in 1 file covered. (78.26%)
2176 of 2390 relevant lines covered (91.05%)
0.91 hits per line
|
import threading |
1✔ |
2 |
import rx |
1✔ |
|
from rx.scheduler import CurrentThreadScheduler |
1✔ |
4 |
|
|
5 |
|
|
6 |
def run(pipe): |
1✔ |
|
exception = None
|
1✔ |
|
latch = threading.Event() |
1✔ |
|
has_result = False
|
1✔ |
|
result = None
|
1✔ |
|
done = False
|
1✔ |
12 |
|
|
|
def on_next(value): |
1✔ |
14 |
nonlocal result, has_result
|
|
|
result = value |
1✔ |
|
has_result = True
|
1✔ |
17 |
|
|
|
def on_error(error): |
1✔ |
19 |
nonlocal exception, done
|
|
20 |
|
|
NEW
|
exception = error |
× |
NEW
|
done = True
|
× |
NEW
|
latch.set() |
× |
24 |
|
|
|
def on_completed() -> None: |
1✔ |
26 |
nonlocal done
|
|
|
done = True
|
1✔ |
|
latch.set() |
1✔ |
29 |
|
|
|
pipe.subscribe(on_next, on_error, on_completed, scheduler=CurrentThreadScheduler()) |
1✔ |
31 |
|
|
|
while not done: |
1✔ |
NEW
|
latch.wait() |
× |
34 |
|
|
|
if exception:
|
1✔ |
NEW
|
raise exception
|
× |
37 |
|
|
|
return result
|
1✔ |