sparckles / Robyn

Robyn is a Super Fast Async Python Web Framework with a Rust runtime.
https://robyn.tech/
BSD 2-Clause "Simplified" License
3.9k stars 198 forks source link

Robyn crashing on use with LanceDB #824

Open sansyrox opened 1 month ago

sansyrox commented 1 month ago

Bug Description

Error message

 objc[30548]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[30548]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. 

Works properly when you do

OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES python3 filename.py

Steps to Reproduce

import chromadb
import lancedb

from robyn import Response, Robyn, jsonify, Request
from langchain.vectorstores import LanceDB

# from langchain.documents import Document

app = Robyn(__file__)

db = lancedb.connect("./.lancedb_test")
data = [{"vector": [1.1, 1.2], "lat": 45.5, "long": -122.7}, {"vector": [0.2, 1.8], "lat": 40.1, "long":  -74.1}]

@app.get("/")
def home():
    # print("This is the new table", db.open_table("my_table_new") )

    data = [
        {"vector": [3.1, 4.1], "item": "foo", "price": 10.0},
        {"vector": [5.9, 26.5], "item": "bar", "price": 20.0},
    ]

# Synchronous client
    tbl = db.open_table("my_table2")
    tbl.add(data)
    return {
        "sucecss": True
    }

if __name__ == "__main__":
    app.start()

Your operating system

Mac OS

Your Python version (python --version)

3.10

Your Robyn version

0.54.5

Additional Info

No response

wjones127 commented 1 month ago

Hi from LanceDB. We unfortunately don't support multiprocessing with fork(). If possible, you should use spawn instead. More detail here: https://github.com/lancedb/lance/issues/2204#issuecomment-2076023640

sansyrox commented 1 month ago

Hey @wjones127 👋

Thanks for letting me know. Unfortunately, robyn doesn't work properly with spawn instead of fork. Let me try and address that