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

Throws timeout if header value is not given in list #1

Closed
prat0318 opened this issue Mar 5, 2015 · 2 comments
Closed

Throws timeout if header value is not given in list #1

prat0318 opened this issue Mar 5, 2015 · 2 comments
Assignees
Labels

Comments

@prat0318
Copy link
Contributor

prat0318 commented Mar 5, 2015

In [22]: fido.fetch("http://google.com", headers={'Accept-Charset': 'utf-8'}).result(timeout=4)
---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)

/nail/home/agarwal/srv/swagger-py/<ipython console> in <module>()

/nail/home/agarwal/mypy/lib/python2.6/site-packages/concurrent/futures/_base.pyc in result(self, timeout)
    407                 return self.__get_result()
    408             else:
--> 409                 raise TimeoutError()
    410
    411     def exception_info(self, timeout=None):

TimeoutError:
@dnephin dnephin added the bug label Mar 5, 2015
@prat0318 prat0318 self-assigned this Mar 5, 2015
prat0318 added a commit to prat0318/fido that referenced this issue Mar 6, 2015
@prat0318
Copy link
Contributor Author

prat0318 commented Mar 9, 2015

On removing the .result() call from above, i found that even though Twisted raises a correct exception, no exception is raised eventually.

In [2]: fido.fetch("http://google.com", headers={'Accept-Charset': 'utf-8'})
Out[2]: <Future at 0x255ed50 state=running>

On adding a debug point and watching the trace, it turns out that Twisted throws back a correct exception Header entry 'Accept-Charset' should be list but found instance of <type 'str'> instead. But it is caught and a future object is always returned back. I could not find out from the trace calls where the exception is caught among this:

  /usr/lib64/python2.6/threading.py(532)__bootstrap_inner()
-> self.run()
  /usr/lib64/python2.6/threading.py(484)run()
-> self.__target(*self.__args, **self.__kwargs)
  /nail/home/agarwal/mypy/lib/python2.6/site-packages/crochet/_eventloop.py(382)<lambda>()
-> target=lambda: self._reactor.run(installSignalHandlers=False),
  /nail/home/agarwal/mypy/lib/python2.6/site-packages/twisted/internet/base.py(1192)run()
-> self.mainLoop()
  /nail/home/agarwal/mypy/lib/python2.6/site-packages/twisted/internet/base.py(1201)mainLoop()
-> self.runUntilCurrent()
  /nail/home/agarwal/mypy/lib/python2.6/site-packages/twisted/internet/base.py(797)runUntilCurrent()
-> f(*a, **kw)
  /nail/home/agarwal/mypy/lib/python2.6/site-packages/crochet/_eventloop.py(416)runs_in_reactor()
-> d = maybeDeferred(function, *args, **kwargs)
  /nail/home/agarwal/mypy/lib/python2.6/site-packages/twisted/internet/defer.py(140)maybeDeferred()
-> result = f(*args, **kw)
  /nail/home/agarwal/srv/fido/fido/fido.py(85)fetch_inner()
-> headers=listify_headers(headers),
  /nail/home/agarwal/srv/fido/common.py(10)listify_headers()
-> return Headers(headers)

But, addding this in fido.py correctly print outs the error:

    try:
        a = Headers(headers)
    except Exception as e:
        print e
Header entry 'Accept-Charset' should be list but found instance of <type 'str'> instead

So, IMO the PR still holds good. It is the creation of the future object which is eating up the exception.

@prat0318 prat0318 mentioned this issue Mar 9, 2015
@dnephin
Copy link

dnephin commented Mar 9, 2015

I think that is the correct behaviour. A future should compose an exception, and it should get raised when we try to resolve the future. But I would not except a TimeoutError, it should be the TypeError about the header.

So there is still another bug here somewhere, masking the original exception.

prat0318 added a commit that referenced this issue Jul 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants