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

http client fails to handle errors properly #42

Open
ghost opened this issue Mar 14, 2013 · 0 comments
Open

http client fails to handle errors properly #42

ghost opened this issue Mar 14, 2013 · 0 comments

Comments

@ghost
Copy link

ghost commented Mar 14, 2013

This may be similar to issue #39. Any exceptions raised during asynchronous operation can't be trapped using try/except. Using set_exception_notifier(...) works though.

I think this is because client.read_thread() method fails to capture and handle exceptions when calling client._read_message(). Further, request and latch objects miss any exception handling functionality.

The following hack worked for me:

from coro.http.client import client as http_client

class http_kludge(http_client):

    def read_thread(self):
        while 1:
            req = self.pending.pop()
            if req is None:
                break
            else:
                try:
                    self._read_message(req)
                except Exception, exc:
                    req.latch.cv.raise_all(exc) # put the exception where it belongs
                else:
                    if not req.response:
                        break
                    else:
                        req.wake()
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

0 participants