Permalink
Browse files

Remove Timeout block from geocode endpoint for being generally unsafe.

The timeout can happen elsewhere (e.g. Unicorn or Gate).
  • Loading branch information...
1 parent 9e3bd5b commit b681fd70d948e21ccafea184e790f81c889ea813 Schuyler Erle committed Jun 8, 2011
Showing with 1 addition and 12 deletions.
  1. +1 −12 lib/geocoder/us/rest.rb
View
@@ -1,24 +1,13 @@
require 'sinatra'
require 'geocoder/us/database'
require 'json'
-require 'timeout'
@@db = Geocoder::US::Database.new(ARGV[0] || ENV["GEOCODER_DB"])
set :port, 8081
get '/geocode' do
if params[:q]
- results = []
- begin
- # TODO: remove this Timeout call?
- # Read this blog post to see why Timeout is very dangerous:
- # http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html
- Timeout.timeout(1.0) do
- results = @@db.geocode params[:q]
- end
- rescue Timeout::Error
- $stderr.print "Timed out on '#{params[:q]}'\n"
- end
+ results = @@db.geocode params[:q]
features = []
results.each do |result|
coords = [result.delete(:lon), result.delete(:lat)]

0 comments on commit b681fd7

Please sign in to comment.