bcg / em-mongo

EventMachine MongoDB Driver (based off of RMongo)
http://github.com/bcg/em-mongo
141 stars 47 forks source link

Connection can not be closed? #52

Closed eax closed 5 years ago

eax commented 10 years ago

Hi

I'm using em-mongo with and without Goliath. There is a weird thing that I'm not able to close a connection:

I've tried conn.close almost everywhere (in and out of callback, out of method, in EM proc etc.), it always keep connection alive which consumes resources on server box

here is a snippet of problem I've reproduced:

def load_items
  org = Fiber.current
  conn = EM::Mongo::Connection.new('localhost')
  database = conn.db('mydb')
  coll = database.collection('itemscoll')
  curs = coll.find({"active" => true}).defer_as_a.callback do |docs|
    docs.each do |doc|
      $items << doc["data"].to_s unless $existing.include?(doc["data"].to_s)
    end
    conn.close
    org.resume
  end
  return Fiber.yield
end

EM.run do
  Fiber.new{
    load_items  
    EM.stop
  }.resume
end
bcg commented 10 years ago

@eax sorry to say, but I'm not maintaining em-mongo anymore and no one has stepped up to the plate to take it over.

jsaak commented 10 years ago

why not use ConnectionPool ? EventMachine and Synchrony (Goliath) both has them