Bryce Codell

08/05/2023, 3:30 AM
@Marvin explain why the following error would occur when using the concurrent task runner on a flow running on AWS ECS:
Copy code
Engine execution of flow run '9decc9c6-f550-4d2e-9472-b4e4c6d91447' exited with unexpected exception
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/prefect/", line 2467, in <module>
File "/usr/local/lib/python3.10/site-packages/prefect/", line 297, in enter_flow_run_engine_from_subprocess
state = from_sync.wait_for_call_in_loop_thread(
File "/usr/local/lib/python3.10/site-packages/prefect/_internal/concurrency/", line 243, in wait_for_call_in_loop_thread
return call.result()
File "/usr/local/lib/python3.10/site-packages/prefect/_internal/concurrency/", line 283, in result
return self.future.result(timeout=timeout)
File "/usr/local/lib/python3.10/site-packages/prefect/_internal/concurrency/", line 169, in result
return self.__get_result()
File "/usr/local/lib/python3.10/concurrent/futures/", line 403, in __get_result
raise self._exception
File "/usr/local/lib/python3.10/site-packages/prefect/_internal/concurrency/", line 346, in _run_async
result = await coro
File "/usr/local/lib/python3.10/site-packages/prefect/client/", line 51, in with_injected_client
return await fn(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/prefect/", line 442, in retrieve_flow_then_begin_flow_run
return await begin_flow_run(
File "/usr/local/lib/python3.10/site-packages/prefect/", line 479, in begin_flow_run
async with AsyncExitStack() as stack:
File "/usr/local/lib/python3.10/", line 714, in __aexit__
raise exc_details[1]
File "/usr/local/lib/python3.10/", line 217, in __aexit__
await self.gen.athrow(typ, value, traceback)
File "/usr/local/lib/python3.10/site-packages/prefect/", line 1903, in report_flow_run_crashes
File "/usr/local/lib/python3.10/", line 697, in __aexit__
cb_suppress = await cb(*exc_details)
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/", line 597, in __aexit__
raise exceptions[0]
File "/usr/local/lib/python3.10/site-packages/prefect/", line 1367, in create_task_run_then_submit
task_run = await create_task_run(
File "/usr/local/lib/python3.10/site-packages/prefect/", line 1412, in create_task_run
task_run = await flow_run_context.client.create_task_run(
File "/usr/local/lib/python3.10/site-packages/prefect/client/", line 1877, in create_task_run
response = await <|>(
File "/usr/local/lib/python3.10/site-packages/httpx/", line 1848, in post
return await self.request(
File "/usr/local/lib/python3.10/site-packages/httpx/", line 1530, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.10/site-packages/prefect/client/", line 251, in send
response = await self._send_with_retry(
File "/usr/local/lib/python3.10/site-packages/prefect/client/", line 193, in _send_with_retry
response = await request()
File "/usr/local/lib/python3.10/site-packages/httpx/", line 1617, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.10/site-packages/httpx/", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.10/site-packages/httpx/", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
File "/usr/local/lib/python3.10/site-packages/httpx/", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
File "/usr/local/lib/python3.10/site-packages/httpx/_transports/", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/", line 262, in handle_async_request
raise exc
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/", line 245, in handle_async_request
response = await connection.handle_async_request(request)
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/", line 96, in handle_async_request
return await self._connection.handle_async_request(request)
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/", line 185, in handle_async_request
raise exc
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/", line 144, in handle_async_request
await self._send_request_body(request=request, stream_id=stream_id)
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/", line 261, in _send_request_body
await self._send_end_stream(request, stream_id)
File "/usr/local/lib/python3.10/site-packages/httpcore/_async/", line 280, in _send_end_stream
File "/usr/local/lib/python3.10/site-packages/h2/", line 883, in end_stream
frames = self.streams[stream_id].end_stream()
KeyError: 569


08/05/2023, 3:31 AM
Oh, the joys of debugging. It's like a never-ending existential crisis. Anyway, let's try to decipher this mess. The error you're seeing is a
KeyError: 569
which is raised at the very end of your traceback in the
file. This error typically occurs when you're trying to access a dictionary key that doesn't exist. In this context, it seems to be related to the HTTP/2 protocol, which Prefect uses for communication. The error is happening when the code is trying to end a stream (
) but the stream with the given
(569 in this case) doesn't exist in the
dictionary. This could be due to a variety of reasons. It's possible that the stream was already closed or never opened in the first place. It could also be a timing issue, where the stream is being closed while another part of the code is still trying to use it. As for why this would occur when using the concurrent task runner on a flow running on AWS ECS, it's hard to say without more context. It could be related to network issues, or perhaps the ECS environment is causing some unexpected behavior. If you're still stuck, I'd recommend reaching out to the Prefect community or checking their documentation for more help. They might be able to provide more specific guidance based on the details of your setup. And remember, even when it feels like the universe is against you, it's probably just a bug in the code. Or maybe the universe really is against you. Who knows?

Bryce Codell

08/05/2023, 3:52 AM
This is an identical issue for reference: