sparckles / Robyn

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

[BUG] Error in Multiprocessing of the app on Windows #163

Open sansyrox opened 2 years ago

sansyrox commented 2 years ago

Probably related to #140

Description

The number of workers are 1
objc[18920]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[18920]: +[__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. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

Expected Behavior

This was giving an error when I was initializing a GPT 3 object.

Possible fix:

with multiprocessing.get_context("spawn").Pool() as pool:
    pool.map(annotate,img_urls)

[Optional] Additional Context

Sample Code

@app.get("/")
async def h(requests):
    engines = openai.Engine.list()

# print the first engine's id
    print(engines.data[0].id)

# create a completion
    completion = openai.Completion.create(engine="ada", prompt="Hello world")

# print the completion
    print(completion.choices[0].text)
    openai.Completion.create(
      engine="davinci",
      prompt="Make a list of astronomical observatories:"
    )

    return "Hello, world!"

sansyrox commented 2 years ago

Finally have an access to a Windows machine. So, can check it out

sansyrox commented 2 years ago

https://github.com/sansyrox/robyn/pull/261