Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7171205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:22:04+00:00 2026-05-28T15:22:04+00:00

I recently switched from mongrel to thin when upgrading to rails 3. Prior to

  • 0

I recently switched from mongrel to thin when upgrading to rails 3. Prior to the switch, we had been using EventMachine without any problem. After switching to thin,whenever EventMachine would be called, the server would bomb and say the variable we return is nil.

From what I understand thin utilizes EventMachine which is probably causing a conflict with the implementation that was used with Mongrel. I haven’t worked with EventMachine much but it seems like I need to run EventMachine inside in another instance to separate it from the EventMachine being used by thin. Am I on the right track? How would I go about instantaneous this to run in its own process separate from Thin’s EventMachine?

Here is a snippet of the EventMachine we currently have implemented

def connect
  EventMachine.run {
    args, options = { 
     :query => @options[:query],
      :head  => @options[:headers]
    }, {
      :connect_timeout    => @options[:timeout],
      :inactivity_timeout => @options[:timeout]
    }   

    args[:body] = @options[:data] if allow_body?
    args[:redirects] = @options[:redirects] if @options[:redirects]

    http = EventMachine::HttpRequest.new(@uri, options).send(@options[:method], args)

    http.errback  {
      @response = HttpConnection::Response.new(http, false, @options[:logger])

      EventMachine.stop
    }   

    http.callback {
      @response = HttpConnection::Response.new(http, true, @options[:logger])

      EventMachine.stop
    }   
  }   

  return @response
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:22:05+00:00Added an answer on May 28, 2026 at 3:22 pm

    Thin already provides and manages an EventMachine reactor, so you don’t need to set one up seperately. I don’t think you need to embed this code in the EventMachine.run {} block for starters.

    There are a few problems with your approach here. Firstly, the returned @response variable will always be nil, because the EventMachine::HttpRequest happens asynchronously, and will not give you any data until you hit the http.callback {} block. Secondly, in each of the EventMachine::HttpRequest callbacks, you’re calling EventMachine.stop. This will have the effect of stopping the thin webserver, which is probably why you’re seeing the server bombing.

    If you’re trying to run this sort of code within a rails app, you might need to find a way to handle the calls asynchronously, so that the app doesn’t hang while waiting for a long-running process to happen. A good approach I’ve used for this is to use Sinatra, which has an async plugin, allowing you to hold open long-running requests. You can then include this in your rails3 app using rails metal, so that requests to your async/eventmachine code are routed to sinatra.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using rspec for a little while and recently switched style from
I recently switched from using Linq to Sql to the Entity Framework. One of
I recently switched from using screen to tmux (obtained through macports), as I like
I recently switched out log4net logging from using config files to being set up
I recently switched from VB to C# and have, for the most part, been
UPDATE: Solution at bottom. I recently switched from using a set up such as
The project I work on has recently been switched from a horribly antiquated revision
I have a Rails (version 3.2.1) project and I recently switched from Ruby 1.8.7
I recently switched from using NSTimer to CVDisplayLink to redraw my OpenGL animation, but
I have recently switched from using Eclipse to IntelliJ, and am preferring the experience.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.