Skip to content

Conversation

@nkitsaini
Copy link
Collaborator

@nkitsaini nkitsaini commented Aug 13, 2025

We shut down a previously started server if present when starting new python udf server.

    _running_server = AwaitableUvicornServer(config) # <---- we have tracked the server
    # Register the functions only if the app is running interactively.
    if app_config.running_interactively:
        app.register_functions(replace=True) # <----- Something goes wrong here


    asyncio.create_task(_running_server.serve()) # <---- server is started here
    await _running_server.wait_for_startup()

In above code if register_functions fails we will be in a state where we think we have a running server but we don't. This results in unvicorn throwing an error has no attribute 'servers' when we try shutdown this not running server.

I have made two changes to fix this (any one would resolve our issue):

  1. Only track _running_server after the function has been registered
  2. Run shutdown only after verifying that previous server actually started

Test

Tested by running this notebook.
An easy way to make register_functions fail is to not select a database.

Copy link
Collaborator

@psachdeva-ss psachdeva-ss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nkitsaini nkitsaini force-pushed the users/asaini/fix-no-attribute-servers branch from bcc5446 to 9c82814 Compare August 13, 2025 08:39
@kesmit13 kesmit13 merged commit 96a2893 into main Aug 13, 2025
11 checks passed
@kesmit13 kesmit13 deleted the users/asaini/fix-no-attribute-servers branch August 13, 2025 13:18
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.

5 participants