Created
August 3, 2015 21:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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