Skip to content

Commit 1b774b2

Browse files
committed
Fix profile server running flag after start conflicts
1 parent 3237fad commit 1b774b2

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/app_profiler/server.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,12 @@ def start_running(stackprof_args)
158158

159159
@profile_running = true
160160

161-
AppProfiler.start(**stackprof_args)
161+
AppProfiler.start(**stackprof_args).tap do |started|
162+
@profile_running = false unless started
163+
end
164+
rescue
165+
@profile_running = false
166+
raise
162167
end
163168
end
164169

md.com

Whitespace-only changes.

test/app_profiler/profile_server_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,19 @@ def app
353353
AppProfiler.stop
354354
end
355355

356+
test "app can start profiling again after external conflict clears" do
357+
begin
358+
AppProfiler.start
359+
get("/profile?duration=0.01")
360+
assert_equal(decode_status(last_response.status), Net::HTTPConflict)
361+
ensure
362+
AppProfiler.stop
363+
end
364+
365+
get("/profile?duration=0.01")
366+
assert(last_response.ok?)
367+
end
368+
356369
private
357370

358371
def with_profiled_workload(workload, &block)

0 commit comments

Comments
 (0)