Skip to content

Commit 7e35375

Browse files
committed
async version of read_loop() must stop on errors.
If I unplug a device, the loop should end with an error, instead of blocking forever.
1 parent af11cb2 commit 7e35375

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎evdev/eventio_async.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ def __anext__(self):
7676
future.set_result(next(self.current_batch))
7777
except StopIteration:
7878
def next_batch_ready(batch):
79-
self.current_batch = batch.result()
80-
future.set_result(next(self.current_batch))
79+
try:
80+
self.current_batch = batch.result()
81+
future.set_result(next(self.current_batch))
82+
except Exception as e:
83+
future.set_exception(e)
8184
self.device.async_read().add_done_callback(next_batch_ready)
8285
return future

0 commit comments

Comments
 (0)