mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: stop running background work between requests
Use a dedicated thread to run Scheduler::Defer This avoids blocking of a worker during operations that require waiting. In particular uploads risked blocking a unicorn. This also add a queue "length" that discourse prometheus consumes.
This commit is contained in:
@@ -8,6 +8,10 @@ module Scheduler
|
||||
@thread = nil
|
||||
end
|
||||
|
||||
def length
|
||||
@queue.length
|
||||
end
|
||||
|
||||
def pause
|
||||
stop!
|
||||
@paused = true
|
||||
@@ -80,16 +84,6 @@ module Scheduler
|
||||
end
|
||||
|
||||
class Defer
|
||||
|
||||
module Unicorn
|
||||
def process_client(client)
|
||||
Defer.pause
|
||||
super(client)
|
||||
Defer.do_all_work
|
||||
Defer.resume
|
||||
end
|
||||
end
|
||||
|
||||
extend Deferrable
|
||||
initialize
|
||||
end
|
||||
|
Reference in New Issue
Block a user