How to get the Server instance in Streamlit version 1.12?

Viewed 190

Until version 1.11, Streamlit had the following way to access the current Server instance:

from streamlit.server.server import Server

Server.get_current()

Now, in version 1.12, it changed to:

from streamlit.web.server import Server

It's ok. But the method get_current() was removed from the class Server.

So, is there another way to get the server instance?

1 Answers

In case there is no other way (if there is, please tell me), the server instance can be found in the object list of the garbage collector:

import gc

for obj in gc.get_objects():
    if type(obj) is Server:
        server = obj
        break
Related