Skip to content
Snippets Groups Projects
Verified Commit def95dd3 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

api: Add in-flight request tracking

parent 8d974a6e
No related branches found
No related tags found
No related merge requests found
...@@ -67,6 +67,7 @@ module MatrixSdk ...@@ -67,6 +67,7 @@ module MatrixSdk
@global_headers.merge!(params.fetch(:global_headers)) if params.key? :global_headers @global_headers.merge!(params.fetch(:global_headers)) if params.key? :global_headers
@synapse = params.fetch(:synapse, true) @synapse = params.fetch(:synapse, true)
@http = nil @http = nil
@inflight = []
self.threadsafe = params.fetch(:threadsafe, :multithread) self.threadsafe = params.fetch(:threadsafe, :multithread)
...@@ -301,6 +302,7 @@ module MatrixSdk ...@@ -301,6 +302,7 @@ module MatrixSdk
loc_http = http loc_http = http
perform_request = proc do perform_request = proc do
@inflight << loc_http
dur_start = Time.now dur_start = Time.now
response = loc_http.request req_obj response = loc_http.request req_obj
dur_end = Time.now dur_end = Time.now
...@@ -308,6 +310,8 @@ module MatrixSdk ...@@ -308,6 +310,8 @@ module MatrixSdk
rescue EOFError rescue EOFError
logger.error 'Socket closed unexpectedly' logger.error 'Socket closed unexpectedly'
raise raise
ensure
@inflight.delete loc_http
end end
if @threadsafe == true if @threadsafe == true
...@@ -356,6 +360,10 @@ module MatrixSdk ...@@ -356,6 +360,10 @@ module MatrixSdk
ret ret
end end
def stop_inflight
@inflight.each(&:finish)
end
private private
def construct_request(method:, url:, **options) def construct_request(method:, url:, **options)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment