I am experiencing a really weird behaviour with Ruby DRb or maybe the problem is dbm. I am using the dbm database with a server, and a client that makes the requests via DRb.
Here's the method with the problem (the database connection is ok) and it is in the server:
def get id
obj = nil
db = DBM.open @name
obj = db[id.to_s]
db.close
return obj
end
This line obj = db[id.to_s]
returns the error connection closed (DRb::DRbConnError)
in the client side.
The thing is if I do this obj = db['1']
it works just fine ('1' is a key in the dbm). Why does this happen? What is wrong with id
? Here's the call in the client side:
DRb.start_service
r = DRbObject.new_with_uri(SERVER_URI)
puts r.get '1'
Why am I getting this error? The same thing happens with this method:
def delete id
db = DBM.open @name
db.delete id
db.close
end
In /lib/drb/drb.rb, it looks like the connection closed error is raised when
sz.nil?
andstr.nil
.what does
obj = db[id.to_s]
return?