unum-cloud / ucall

Web Serving and Remote Procedure Calls at 50x lower latency and 70x higher bandwidth than FastAPI, implementing JSON-RPC & REST over io_uring ☎️
https://unum-cloud.github.io/ucall/
Apache License 2.0
1.14k stars 43 forks source link

Bug: Server initialization sometimes fails on macOS #107

Open laclouis5 opened 3 months ago

laclouis5 commented 3 months ago

Describe the bug

When restarting a server rapidly after stopping it, it usually fails with this error:

Traceback (most recent call last):
    server = Server()
             ^^^^^^^^
    self.server = ucall.Server(**kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Server Initialization

Steps to reproduce

Setup a simple server (using Python):

from ucall.rich_posix import Server

server = Server()

@server
def test(name: str) -> str:
    return f"Hello, {name}!"

def main():
    server.run()

if __name__ == "__main__":
    main()

Run it (let's call the file api.py):

python api.py

In a new shell issue a request to the API:

ucall test name=Louis --uri 0.0.0.0 --port 8545

After the response control+C the server to quit it, then try to restart the server using the same command as above. This fails with the aforementioned error during around 5 to 10 seconds.

Expected behavior

Server restart should not fail.

UCall version

v0.5.4

Operating System

macOS Sonoma 14.5

Hardware architecture

Arm

Which interface are you using?

Official Python bindings

Which implementation are you using?

POSIX

Contact Details

lac.louis5@gmail.com

Is there an existing issue for this?

Code of Conduct

ashvardanian commented 3 months ago

It may be the case that the port is not being reclaimed in time. The v1 of UCall will have a drastically different design and set of capabilities. Hopefully this will be resolved along the way. Thank you for reporting, @laclouis5 🤗