Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Producer not being unregistered when wrapping static.File #28

Closed
ldanielburr opened this issue Nov 13, 2013 · 12 comments
Closed

Producer not being unregistered when wrapping static.File #28

ldanielburr opened this issue Nov 13, 2013 · 12 comments

Comments

@ldanielburr
Copy link

(Using Klein master and Twisted 13.2.0)

Hi, just started using Klein for a small project, and I noticed that whenever I return static.File from a route-decorated function or method, I will intermittently see "Producer was not unregistered" when accessing files in the directory being served by static.File.

Plain old twisted.web works, this error only shows up when using Klein.

Simple example, run with "twistd --nodaemon web --class=testing.resource":

testing.py

from klein import resource, route

from twisted.web import static


@route('/files/', branch=True)
def files(request):
    return static.File('/Some/Directory/')

And lastly, the traceback from the logfile:

2013-11-13 10:47:26-0600 [HTTPChannel,0,127.0.0.1] 127.0.0.1 - - [13/Nov/2013:16:47:25 +0000] "GET /files/robots.txt HTTP/1.1" 200 27 "http://127.0.0.1:8080/files/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.71 (KHTML, like Gecko) Version/6.1 Safari/537.71"
2013-11-13 10:47:26-0600 [HTTPChannel,0,127.0.0.1] Unhandled Error
Traceback (most recent call last):
Failure: exceptions.RuntimeError: Producer was not unregistered for /files/robots.txt

@hawkowl
Copy link
Member

hawkowl commented Nov 24, 2013

It seems to be a Twisted 13.2 thing, not sure how I didn't catch it in my testing, since I use Klein pretty heavily...

@dreid
Copy link
Contributor

dreid commented Nov 25, 2013

@hawkowl Is there anything klein can do to work around it?

Do you have a reference to a ticket for it?

@hawkowl
Copy link
Member

hawkowl commented Nov 26, 2013

I'm not actually sure what's causing it yet - I do know that it's only happened for me in Twisted 13.2, though.

I'll try to figure out what's changed in File between 13.1 and 13.2, and make up a patch if it's something I can fix.

@hawkowl
Copy link
Member

hawkowl commented Nov 26, 2013

Nope, this isn't a Twisted bug, this is a Klein bug. Works in 0.2.0 and 0.2.1, but not in 0.2.2. looks for why

@hawkowl
Copy link
Member

hawkowl commented Nov 26, 2013

PR above fixes this for me.

@hawkowl
Copy link
Member

hawkowl commented Nov 26, 2013

It fixes it, but it's actually wrong - from discussion on IRC with @dreid , it looks like some rejiggering of the callback chain could fix this. I'll try and get a look in today.

@hawkowl
Copy link
Member

hawkowl commented Dec 4, 2013

I guess I should mention here that PR30 is "done", and is awaiting someone to take a look.

@hawkowl
Copy link
Member

hawkowl commented Jan 4, 2014

This is merged! Should work fine now.

@hawkowl hawkowl closed this as completed Jan 4, 2014
@ldanielburr
Copy link
Author

Indeed it does! Thanks much.

@hawkowl
Copy link
Member

hawkowl commented Jan 4, 2014

You're welcome! Sorry it took so long, but it's in there now! :)

@dpnova
Copy link

dpnova commented Jan 14, 2014

FWIW this fix works for me too on 13.2 + ubuntu 12.04.

Thanks heaps!

@hawkowl
Copy link
Member

hawkowl commented Jan 15, 2014

Hi, this is now on the version on pypi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants