You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: shared.rb
    path of file: ./repos/pakyow/core/spec/integration/runnable
    
    the code of the file until where you have to start completion: require "timeout"

RSpec.shared_context "runnable container" do
  before do
    if run_options[:strategy] == :threaded
      allow(Process
    
  def listen_for(length:, timeout: nil)
    with_timeout(timeout) do |task|
      start = Time.now

      until messages.length >= length
        task.sleep 0.1
      end

      yield messages.take(length), Time.now - start if block_given?
    end