Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
EM.threadpool_size = 10
class ::RainbowsEventMachineThreadPoolClient <
Rainbows::EventMachine::Client
def app_call input
set_comm_inactivity_timeout 0
@env[RACK_INPUT] = input
@env[REMOTE_ADDR] = @_io.kgio_addr
@env[ASYNC_CALLBACK] = method(:write_async_response)
@env[ASYNC_CLOSE] = EM::DefaultDeferrable.new
@deferred = true
EM.defer{
begin
status, headers, body = catch(:async) {
APP.call(@env.merge!(RACK_DEFAULTS))
}
if nil == status || -1 == status
@deferred = true
else
@deferred = nil
ev_write_response(status, headers, body, @hp.next?)
end
rescue Exception => e
EM.instance_variable_get(:@error_handler).call(e)
handle_error(e)
end
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.