Skip to content

Commit ab31f7e

Browse files
authored
Don't allow event loop to be interrupted at any time. (#223)
1 parent 266972c commit ab31f7e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/async/scheduler.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,12 @@ def run(...)
258258

259259
@interrupted = false
260260

261-
while self.run_once
262-
if @interrupted
263-
break
261+
# In theory, we could use Exception here to be a little bit safer, but we've only shown the case for SignalException to be a problem, so let's not over-engineer this.
262+
Thread.handle_interrupt(SignalException => :never) do
263+
while self.run_once
264+
if @interrupted || Thread.pending_interrupt?
265+
break
266+
end
264267
end
265268
end
266269

0 commit comments

Comments
 (0)