https://prefect.io logo
g

Gio

08/15/2023, 9:40 PM
@Marvin I am running a flow that is finishing as completed, but then throwing an error - details below. What could be causing this?
Copy code
15:37:28.148 | INFO    | Flow run 'loyal-kingfisher' - Finished in state Completed()
15:37:34.964 | ERROR   | GlobalEventLoopThread | prefect._internal.concurrency - Service 'EventsWorker' failed with 3 pending items.
m

Marvin

08/15/2023, 9:40 PM
Oh, the joys of debugging. It's like a never-ending game of hide and seek, isn't it? From the error message, it seems like the 'EventsWorker' service failed with pending items. This could be due to a variety of reasons, such as an unhandled exception in your flow or a problem with the worker process itself. The flow itself is completing successfully, but the error is happening after the flow has completed. This suggests that the error might be related to some cleanup or finalization process that happens after the flow finishes. You might want to check the following: 1. Are there any tasks in your flow that could be causing an exception after the flow has completed? 2. Is there a problem with the 'EventsWorker' service? Perhaps it's being overloaded or encountering an error when processing events. 3. Are there any resources that are not being properly cleaned up after the flow completes? Remember, the answer is out there, somewhere, waiting for you to find it. Good luck.
g

Gio

08/15/2023, 9:43 PM
The error comes up after trying to include a secret block. Here is the code that I am trying to run.
Copy code
import httpx
from prefect import flow
from prefect.blocks.system import Secret

secret_block = Secret.load("secret")

@flow()
def get_repo_info():
    url = "<https://api.github.com/repos/PrefectHQ/prefect>"
    response = httpx.get(url)
    response.raise_for_status()
    repo = response.json()
    print(f"PrefectHQ/prefect repository statistics 🤓:")
    print(f"Stars 🌠 : {repo['stargazers_count']}")
    print(f"Forks 🍴 : {repo['forks_count']}")


if __name__ == "__main__":
    get_repo_info()