diff --git a/lib/logtail/log_devices/http.rb b/lib/logtail/log_devices/http.rb index 331bf34..48b6edf 100755 --- a/lib/logtail/log_devices/http.rb +++ b/lib/logtail/log_devices/http.rb @@ -119,13 +119,13 @@ def flush # Closes the log device, cleans up, and attempts one last delivery. def close # Kill the flush thread immediately since we are about to flush again. - @flush_thread.kill if @flush_thread + @flush_thread.kill.join if @flush_thread # Flush all remaining messages flush # Kill the request queue thread. Flushing ensures that no requests are pending. - @request_outlet_thread.kill if @request_outlet_thread + @request_outlet_thread.kill.join if @request_outlet_thread end def deliver_one(msg) diff --git a/spec/logtail/log_devices/http_spec.rb b/spec/logtail/log_devices/http_spec.rb index fad540e..9ae0743 100755 --- a/spec/logtail/log_devices/http_spec.rb +++ b/spec/logtail/log_devices/http_spec.rb @@ -57,10 +57,8 @@ http.send(:ensure_flush_threads_are_started) http.close thread = http.instance_variable_get(:@flush_thread) - sleep 0.1 # too fast! expect(thread).to_not be_alive thread = http.instance_variable_get(:@request_outlet_thread) - sleep 0.1 # too fast! expect(thread).to_not be_alive end