Skip to content

Fix 39c serverless example: bind mock server inside __main__ - #513

Open
nthmost-orkes wants to merge 1 commit into
mainfrom
fix/serverless-example-port-rebind
Open

nthmost-orkes wants to merge 1 commit into
mainfrom
fix/serverless-example-port-rebind

Conversation

@nthmost-orkes

Copy link
Copy Markdown
Contributor

What

The 39c_serverless_code_execution.py example bound its mock execution server to port 9753 at module level:

mock_server = _start_mock_server(port=9753)

AgentRuntime re-imports the example file in its worker process. On re-import the worker hit that same line, tried to bind port 9753 a second time, and died with Address already in use — so the example never completed.

Fix

Move the bind inside the if __name__ == "__main__": guard. The worker's re-import evaluates the module but skips __main__, so it never re-binds. The Agent definition stays at module level (it only holds config and binds nothing), so the worker still imports everything it needs.

User impact

Running the serverless code-execution example would crash the moment the agent worker spun up (Address already in use), so it never produced a result. Now the port is bound once in the main process and the worker runs cleanly against it.

Fixes #512

The mock execution server was bound to port 9753 at module level.
AgentRuntime re-imports the example in its worker process, so the
worker hit the same bind and failed with "Address already in use",
killing the worker.

Move the bind inside the __main__ guard so the worker's re-import
skips it. The Agent definition stays at module level (it only holds
config and binds nothing), so the worker still gets what it needs.

Fixes #512
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example 39c_serverless_code_execution.py needs to be changed for it to work

1 participant