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

CancelledError when running on apify infrastructure #309

Open
krasnoludkolo opened this issue Oct 28, 2024 · 1 comment
Open

CancelledError when running on apify infrastructure #309

krasnoludkolo opened this issue Oct 28, 2024 · 1 comment
Labels
t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@krasnoludkolo
Copy link

Hello.
I'm running my actors on apify infrastructure and low % of runs ends with:

  Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 1289, in close_connection
    await self.transfer_data_task
  File "/usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 966, in transfer_data
    await asyncio.shield(self._put_message_waiter)
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/apify/event_manager.py", line 222, in _process_platform_messages
    async for message in websocket:
  File "/usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 494, in __aiter__
    yield await self.recv()
          ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 564, in recv
    await self.ensure_open()
  File "/usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 940, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: sent 1011 (internal error) keepalive ping timeout; no close frame received

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/src/main.py", line 24, in main
    async with Actor:
  File "/usr/local/lib/python3.11/site-packages/apify/actor.py", line 65, in __aexit__
    await Actor.exit()
  File "/usr/local/lib/python3.11/site-packages/apify/actor.py", line 318, in exit
    return await cls._get_default_instance().exit(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/apify/actor.py", line 352, in _exit_internal
    await self._event_manager.close(event_listeners_timeout_secs=event_listeners_timeout_secs)
  File "/usr/local/lib/python3.11/site-packages/apify/event_manager.py", line 90, in close
    await self._process_platform_messages_task
  File "/usr/local/lib/python3.11/site-packages/apify/event_manager.py", line 236, in _process_platform_messages
    self._connected_to_platform_websocket.set_result(False)
asyncio.exceptions.InvalidStateError: invalid state

I'm using 2.0.0 version, however issue was observed on 1.x.x as well

Is there anything I can do about it?

@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 28, 2024
@vdusek
Copy link
Contributor

vdusek commented Oct 29, 2024

Hey @krasnoludkolo, we will need more information to reproduce the problem and help you.

  1. Could you provide us versions of the software you are using (Apify SDK, websockets, ...) - you can use pip freeze.
  2. Could you provide us a minimal reproducible example? Share a small snippet of the code you are using, or describe the specific steps that lead to this issue. So that we are able to reproduce the error.
  3. Since it seems websockets-related, I believe it is happening only when running on the Apify Platform, right? You have no issues running it locally, correct?
  4. Could you provide more detailed logs from Apify's platform? Or any other relevant information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

No branches or pull requests

2 participants