docs: def _refresh_connection(self):
          """Refresh connection to Elasticsearch when worker is started.
  
          File descriptors (sockets) can be shared between multiple
          threads. If same connection is used by multiple threads at the
          same time, this can cause timeouts in some of the pushes. So
          connection needs to be reestablished in each thread to make sure
          that it is unique per thread.
          """
          # Thread with same id can be created when one terminates, but it
          # is ok, as we are only concerned about concurent pushes.
          current_thread_id = threading.current_thread().ident
  
          if current_thread_id != self.connection_thread_id:
              prepare_connection()
  
              self.connection_thread_id = current_thread_id