Comments (48)
Hi - where and when does this happen?
from dragonfly.
also, what's your configuration? or are you using 'dragonfly/rails/images' ?
from dragonfly.
yes, I am using dragonfly/rails/images
from dragonfly.
the error does not happen all the time. only sometimes.
from dragonfly.
this is the complete stack
http://pastie.org/1160936
from dragonfly.
Do you have a backtrace? Also what environment is it running on? Is it passenger?
Thanks
from dragonfly.
locally I'm using mongrel, but the error also occurs on passenger + nginx.
Thank you.
from dragonfly.
this line is shooting the error, sometimes.
= image_tag featured.photos.first.image.thumb("70x70#").url
from dragonfly.
i am getting this error also. using rails 3 webrick. can't work out the pattern to make it fail all the time. it happens often though.
from dragonfly.
I've seen this once or twice, but can't for the life of me work out what's causing it...
One test fails with it when running 'rake spec', but not when running the file on its own.
It seems to always happen in Tempfile#close
Any help would be appreciated! :)
from dragonfly.
Annoyingly, this appears to be a bug in Tempfile (which is fixed in Ruby 1.9.2)
http://redmine.ruby-lang.org/issues/show/3119
This post:
http://labnotes.org/2009/09/01/ruby-1-9-1-p234passenger-2-2-5-tempfile-rb-fix/
points out a fix
http://redmine.ruby-lang.org/repositories/diff/ruby-19/lib/tempfile.rb?rev=23494
which seems to work for me:
putting
require 'tempfile'
class Tempfile
def unlink
# keep this order for thread safeness
begin
if File.exist?(@tmpname)
closed? or close
File.unlink(@tmpname)
end
@@cleanlist.delete(@tmpname)
@data = @tmpname = nil
ObjectSpace.undefine_finalizer(self)
rescue Errno::EACCES
# may not be able to unlink on Windows; just ignore
end
end
end
in an initializer hopefully does the trick.
Ideally I don't really want to have to include this fix in Dragonfly. I don't know if there's another way around it...
from dragonfly.
I put this inside the dragonfly initialisation file and i still get the error. i am using ruby ee "ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.4.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02"
it is annoying that it isn't consistently repeatable.
from dragonfly.
It is indeed very annoying.
I see that Rack has a patch for this http://rack.rubyforge.org/doc/Rack/RewindableInput/Tempfile.html
What happens if, instead of putting the patch I pasted above, you include this patch?
require 'tempfile'
class Tempfile
def _close
@tmpfile.close if @tmpfile
@data[1] = nil if @data
@tmpfile = nil
end
end
Please let me know and if it fixes it I'll use it in the next version
from dragonfly.
I have the same problem using rvm ruby-1.8.7-p174 with Rails 2.3.9
I used both patch methods, it did not work.
I still get this error.
Read error: #<IOError: closed stream>
/.rvm/rubies/ruby-1.8.7-p174/lib/ruby/1.8/tempfile.rb:167:in close' /.rvm/rubies/ruby-1.8.7-p174/lib/ruby/1.8/tempfile.rb:167:in
callback'
/.rvm/gems/ruby-1.8.7-p174/gems/builder-2.1.2/lib/blankslate.rb:84:in call' /.rvm/gems/ruby-1.8.7-p174/gems/builder-2.1.2/lib/blankslate.rb:84:in
method_added'
from dragonfly.
Sorry mark still no dice. i will do some digging and let you know if i find anything that may help
from dragonfly.
I also have the same problem
./.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/tempfile.rb:167:in `close'
/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/tempfile.rb:167
seems to happen randomly. but seemed to occur maore when i was copying images in a callback
one.image = two.image
one.save
both patches did not work
from dragonfly.
I experience this issue on my OS X workstation, but I don't see it on my FreeBSD. It could be the different between the platforms or just that I run in dev mode locally and production mode on the server.
from dragonfly.
I am seeing it on my engine yard server which runs in production mode, not sure what platform that runs on
from dragonfly.
Hi,
Sorry to be a moaner but is this issue being looked at. I was definitely not getting this error until I updated to the current version of dragonfly (from 0.5.2)
I am trying to go live in the next couple of weeks and the intermittent errors are making that hard.
I may just roll back to 0.5.2 until this gets fixed or I get time to look at the bug.
Again sorry to be a moaner, I know how hard it can be maintaining software and it is a really great library!
from dragonfly.
Hi
I've looked at it a few times but with no luck - the problem is it's not easily reproduceable because it only happens sporadically. I assume it's something to do with tempfile closing on garbage collection but can't be sure.
I haven't had much time recently and still intend to fix it of course, but would really appreciate any other help on it
from dragonfly.
I've got the same error:
Started GET "/refinery/dialogs/Link" for 127.0.0.1 at Wed Oct 06 12:38:26 -0300 2010
IOError (closed stream):
Using ree1.8.7 with MacOSx
from dragonfly.
Mark, would it be helpful to create a ruby script that is able to reproduce this problem ? It could help in making some realizations about what exactly is going wrong. It would also mean that, if needed, we have a snippet of code that we could have some ruby maven look at.
Luke
from dragonfly.
Same problem here, I have this error when trying to upload images from a web url using open(url).read
from dragonfly.
That's interesting. I also have a few:
open(url).read
lines in my code. Could it be that these are being left open then the error is triggered on garbage collection?
from dragonfly.
Does that mean we need to use a block to close the read?
And why do my error stacks always reference tempfile?
from dragonfly.
In the Rack lib...
When I commented the line 167 in tempfile.rb everything works well....
from dragonfly.
Did you mean you commented out line 167 in tempfile.rb in Rack?
Have you got more details, maybe a gist?
from dragonfly.
I'm using refinerycms (that use drangonfy to manipulate the size of images) and the IOError stopped when I commented that line (167).
In my case: /Users/fabio/.rvm/rubies/ree-1.8.7-2010.01/lib/ruby/1.8/tempfile.rb
from dragonfly.
@lcowell - yes that would be very helpful thanks for the suggestion. I've already created one which I can now consistently recreate the error, however it needs rails runner to reproduce the error - plain old ruby works fine, even though it's not using rails at all.
It's still tricky to track down though.
@fabiotc - thanks for the tip, though I imagine getting rid of tempfile.close could have some other unwanted side effects? (e.g. tempfiles not getting cleaned up properly?)
from dragonfly.
+1
from dragonfly.
@markevans Did you have a gist of the script to reproduce the error. Maybe some of us may be able to help figure it out
from dragonfly.
@ben - I can reproduce it on my computer by doing the following:
-
create a new rails app
-
create a file in the app test.rb with contents:
require 'tempfile'
1000.times do
Tempfile.new('a').open.close
end -
"rails runner test.rb"
As you can see, this happens without dragonfly even being in the project.
I got to this script by using dragonfly and gradually taking away things which were irrelevant.
I get the impression it's some kind of bug with Tempfile that using dragonfly exposes more than usual due to its use of Tempfile.
By the way, you might be able to get round it anyway by using
app.configure_with(:rmagick, :use_filesystem => false)
in your config (see http://markevans.github.com/dragonfly/file.Configuration.html RMagick section)
This use of RMagick is more memory intensive but might be better for some projects.
from dragonfly.
or even
require 'tempfile'
"a"
Tempfile.new('a').open.close
Tempfile.new('a').open.close
GC.start
reproduces the error (when run with rails runner - can't make it happen with ruby only)
from dragonfly.
Cheers for the tip. A combination of using memory and caching should buy me some more time until the problem is solved.
Sounds like this should be submitted as a bug in ruby 1.8.7
from dragonfly.
@mark do you still get the error if you change your script above to:
require 'tempfile'
"a"
a = Tempfile.new('a')
a.open.close
b = Tempfile.new('a')
b.open.close
GC.start
your script above does fail reliably on my machine however when changed to the above it doesn't. I don't know why this would be. But food for thought.
from dragonfly.
@snicolson - I get the same as you. I imagine it's because GC.start doesn't garbage-collect the tempfiles as they're assigned to still used variables (a and b)
from dragonfly.
Skipping tmp files worked like a charm!
app.configure_with(:rmagick, :use_filesystem => false)
For those using Rails the following works to get the configuration set inside of your rails application.
config/initializers/dragonfly.rb
require 'dragonfly/rails/images' app = Dragonfly[:images] app.configure_with(:rmagick, :use_filesystem => false)
from dragonfly.
sadly for me when I set it my app is crashing after 40-70 requests for too many open files... this error is appearing only on my development platform (osx), so it's ok, i just restart my local server
from dragonfly.
Right - I think I've managed to fix this - check out version 0.7.7 (on rubygems)
It arises from closing the File object returned by tempfile.open, instead of closing the Tempfile object itself (which in turn closes the File object).
I don't know whether that's a ruby 1.8.7 bug or not, but closing the Tempfile itself seems to have fixed the problem.
PLEASE let me know if this fixes it and then I will close this ticket!!!
Thanks
from dragonfly.
Haven't seen this not once since using 0.7.7 on my RefineryCMS app
So far so good Mark! I'll let you know the minute I see one (which hopefully means never)
from dragonfly.
awesome! good to hear.
from dragonfly.
this seems to be fixed so I'm going to close this ticket
from dragonfly.
I haven't seen the problem at all since upgrading to 0.7.7, great!
from dragonfly.
Just a heads up. I started experiencing this error with every image upload when I installed the meta_request gem. The upload completes successfully though. I have been unable to determine which gem is at 'fault'.
from dragonfly.
I'm also experiencing this issue as @mark100net commented. I'm removing meta_request for now waiting for a fix.
from dragonfly.
Had the same issue. Removing meta_request from the gemfile fixed it.
from dragonfly.
+1 Removing meta_request
from the gemfile fixed it.
from dragonfly.
Updating to meta_request-0.3.0 seems to have fixed the problem for me.
from dragonfly.
Related Issues (20)
- Can't store resized pdf as jpg HOT 5
- Requesting filename without download file for custom stores HOT 2
- Turning Off Logs HOT 1
- Dragonfly unit test cases failing in Rails 4 HOT 1
- Dragonfly::FileDataStore::UnableToFormUrl: you need to configure server_root for Dragonfly::FileDataStore in order to form urls
- How to ignore "Dragonfly::FileDataStore destroy error"?
- Adding the ability to specify headers for a URL based attachment HOT 3
- Fetching url in the background
- after_assign's copy_to doesn't fire when using retained_image HOT 1
- SSL verification mode option
- warning: loading in progress, circular require considered harmful HOT 1
- is this version of Dragonfly compatible ? HOT 4
- Support for posix-spawn? HOT 2
- Security Issue Report HOT 1
- Guidance on upgrading to 1.4.0 HOT 7
- validate problems?
- CSS style color raising InvalidParameter when using plain generator HOT 1
- Questions about GHSA-qrgf-jqqm-x7xv HOT 2
- Allowing quality and interlace params for imagemagick thumb processor
- Unable to get dragonfly server to work with CORS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dragonfly.