Skip to content

Existing Embedded Client fails creation of other Embedded Client instances for the same port #1967

@Spikhalskiy

Description

@Spikhalskiy

Current Behavior

Currently, if I attempt to do

    client1 = weaviate.connect_to_embedded()
    client2 = weaviate.connect_to_embedded()

The following error is thrown:

weaviate.exceptions.WeaviateStartUpError: Embedded DB did not start because processes are already listening on ports http:8079 and grpc:50050use weaviate.connect_to_local(port=8079, grpc_port=50050) to connect to the existing instance

This is not just inconvenient and calling for the need for the embedded client to be a singleton, but it's contradicting the method specification, as according to it, the embedded client can be created and used as a context manager:

Alternatively, you can use the client as a context manager
in a `with` statement, which will automatically close the connection when the context is exited.

################## With Context Manager #############################
>>> import weaviate
>>> with weaviate.connect_to_embedded(port=8080, grpc_port=50051) as client:

It will only work if no two threads ever create a context manager for a client on the same port.

Expected behavior

connect_to_embedded and use_async_with_embedded should allow multiple instances to be created with the same ports. This will be a convenient and compliant implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions