Skip to content

Instantly share code, notes, and snippets.

@thwarted
Created August 3, 2015 21:58
Show Gist options
  • Save thwarted/76a16b2d208ffe2ac223 to your computer and use it in GitHub Desktop.
Save thwarted/76a16b2d208ffe2ac223 to your computer and use it in GitHub Desktop.
test case for "An error occured on select: 4" in typhoeus/ethon; start httppause and then run makerequest.rb
#!/bin/bash
if [[ "$NESTED" ]]; then
IFS=$( echo -e '\r' )
while read line; do
[[ -z "$line" ]] && break
done
sleep 10
echo -e 'HTTP/1.1 200 OK\r'
echo -e 'Connection: close\r'
echo -e 'Content-length: 5\r'
echo -e '\r'
echo "done"
else
export NESTED=1
exec socat -x TCP-LISTEN:9991,fork SYSTEM:$0,pipes
fi
#!/usr/bin/ruby
require 'typhoeus'
def parent(cpid)
sleep 5
Process.kill("USR1", cpid)
Process.wait
end
def child
Signal.trap("USR1") do
puts "USR1 interrupted"
end
hydra = Typhoeus::Hydra.hydra
8.times do
request = Typhoeus::Request.new('http://localhost:9991/', method: :get)
request.on_complete do |response|
puts response.body
end
hydra.queue(request)
end
hydra.run
end
if pid = fork
parent pid
else
child
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment