Skip to content

Commit

Permalink
fix: replace recursion with while loop in FFMPEG::Timeout to avoid Sy…
Browse files Browse the repository at this point in the history
…stemStackError
  • Loading branch information
bajankristof committed Jun 18, 2024
1 parent fc5278f commit 1dbc71c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/ffmpeg/timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def pause

def resume
@paused = false
tick
end

def tick
Expand All @@ -42,12 +43,9 @@ def initialize(duration, message = nil)
end

def loop
if !@paused && Time.now - @last_tick >= @duration
@current_thread.raise(::Timeout::Error, @message || self.class.name)
else
sleep 0.1
loop
end
sleep 0.1 while @paused || Time.now - @last_tick <= @duration

@current_thread.raise(::Timeout::Error, @message || self.class.name)
end
end
end

0 comments on commit 1dbc71c

Please sign in to comment.