Coder Social home page Coder Social logo

Comments (4)

spaceone avatar spaceone commented on July 19, 2024

Also no luck via client._set_timeout(0) or client._handle_timeout().

from tornado.

bdarnell avatar bdarnell commented on July 19, 2024

Tornado has never had good support for cancellation; this is actually one of our oldest open bugs: #157 (closing this as a duplicate of that one). Currently the best you can do is just let the request run to completion and manage your timeouts and max_clients parameter accordingly.

from tornado.

spaceone avatar spaceone commented on July 19, 2024

@bdarnell
well, unfortunate I have to do more than your suggestions, so I am client.close() ing the connection of CurlAsyncHTTPClient manually.
That should be allowed, right? As the close() method is publicly documented.
That closing works fine except that I run into follow up errors with new instances of the client:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tornado/http1connection.py", line 735, in _server_request_loop
    ret = yield conn.read_response(request_delegate)
  File "/usr/lib/python3/dist-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/usr/lib/python3/dist-packages/tornado/gen.py", line 1147, in run
    yielded = self.gen.send(value)
  File "/usr/lib/python3/dist-packages/tornado/http1connection.py", line 245, in _read_message
    self.stream.set_close_callback(self._on_connection_close)
  File "/usr/lib/python3/dist-packages/tornado/iostream.py", line 606, in set_close_callback
    self._maybe_add_error_listener()
  File "/usr/lib/python3/dist-packages/tornado/iostream.py", line 1128, in _maybe_add_error_listener
    self._add_io_state(ioloop.IOLoop.READ)
  File "/usr/lib/python3/dist-packages/tornado/iostream.py", line 1158, in _add_io_state
    self.fileno(), self._handle_events, self._state)
  File "/usr/lib/python3/dist-packages/tornado/platform/asyncio.py", line 76, in add_handler
    raise ValueError("fd %s added twice" % fd)
ValueError: fd 17 added twice

Could it be that the close() doesn't unregister the socket from asyncio and if the same file descriptor number is then re-used by the kernel the above exception happens?
Is there some call I should do to unregister the socket(s)?

I think curl should already do this via:
self._multi.setopt(pycurl.M_SOCKETFUNCTION, self._handle_socket)

and

115         if event == pycurl.POLL_REMOVE:
116             if fd in self._fds:
117                 self.io_loop.remove_handler(fd)
118                 del self._fds[fd]

from tornado.

bdarnell avatar bdarnell commented on July 19, 2024

CurlAsyncHTTPClient.close is documented, but it's not very well tested; in particular I don't think I've ever tested closing an HTTP client unless either there are no active requests or the entire process is terminating. So it looks like you've found a bug; I don't know what's required to close out an active curl http client cleanly.

from tornado.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.