Skip to content

AttributeError: 'NoneType' object has no attribute 'cancel' #1720

Closed
@julien-duponchelle

Description

Long story short

With recent 1.3 release we start to receive this kind of crash report.

AttributeError: 'NoneType' object has no attribute 'cancel'
  File "gns3server/controller/compute.py", line 502, in _run_http_query
    response = yield from self._session().request(method, url, headers=headers, data=data, auth=self._auth, chunked=chunked, timeout=timeout)
  File "aiohttp/client.py", line 583, in __iter__
    resp = yield from self._coro
  File "aiohttp/client.py", line 279, in _request
    resp.connection.add_callback(handle.cancel)

AttributeError: 'NoneType' object has no attribute 'cancel'

The problem start with this commit: 4be5043

The problem seem to arrive when we pass timeout=None to request. But it doesn't seem to be always the case.

The problem in _request is if you pass None to the TimeoutHandle you will get a None handle

# timeout is cumulative for all request operations
# (request, redirects, responses, data consuming)
tm = TimeoutHandle(timeout)
handle = tm.handle(self._loop)

And we will use this handle later:

        if resp.connection is not None:
            resp.connection.add_callback(handle.cancel)
        else:
            handle.cancel()

The code of handle in TimeoutHandle:

    def handle(self, loop):
        if self._timeout is not None and self._timeout > 0:
            at = ceil(loop.time() + self._timeout)
            return loop.call_at(at, self.__call__)

Is it wrong to pass None as a timeout?

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions