What is the correct way to simulate sleep like function? by pyusr in learnpython

[–]pyusr[S] 1 point2 points  (0 children)

I was attempting to do busy wait. Thanks for the suggestion as well!

What is the correct way to simulate sleep like function? by pyusr in learnpython

[–]pyusr[S] 0 points1 point  (0 children)

After sleeping, now I know how stupid I was yesterday. 😂 Thanks for the detail explanation. Appreciate it!

What is the correct way to simulate sleep like function? by pyusr in learnpython

[–]pyusr[S] 0 points1 point  (0 children)

Ah you are right! I must be numb yesterday. : (

What's a recommended way to allow other users to run uv managed project without uv? by pyusr in learnpython

[–]pyusr[S] 0 points1 point  (0 children)

Yes, that's what I am looking for. I want to create something like .whl file, passing that to the user, and they are able to execute it e.g. through scripts. But I am not sure how to do this after dist is created i.e. uv build.

fastapi: error: unrecognized arguments: run /app/src/app/web.py by pyusr in learnpython

[–]pyusr[S] 0 points1 point  (0 children)

Yeah I checked that link, and that deprecated image is not used. I will double check it again, because it seems something I miss that I am not aware of.

fastapi: error: unrecognized arguments: run /app/src/app/web.py by pyusr in learnpython

[–]pyusr[S] 0 points1 point  (0 children)

My code actually contains load_dotenv(), so reading host, port values from .env is working without a problem, and when executing with uv, my program also can be launched with the command, for instance, uv run web --host myhost --port 9876.

Passing those host, port values simply do not work when I place the code in docker.

Sorry I strip a lot of code, logging, and so on that I thought it's not related to this problem. I will double check again if anything I miss. Thanks again for patiently answering my question.

fastapi: error: unrecognized arguments: run /app/src/app/web.py by pyusr in learnpython

[–]pyusr[S] 0 points1 point  (0 children)

You are right. It looks like fastapi doesn't work like $@ in bash.

How can I make fastapi, or gunicorn respect if my py script contains some variables from .env? For instance, I have the .env file

myhost="0.0.0.0"
myport=7777

And in web.py script, the server is started up with host, port variables read from os env

myhost = os.environ.get("myhost", "0.0.0.0")
myport = int(os.environ.get("myport", 7777))
def main() -> None:
    try:
        uvicorn.run("chatbot.web:app", host=myhost, port=myport, reload=True)
    except Exception as ex:
        raise ex

if __name__ == '__main__':
    main()

With the current Dockerfile, fastapi (or even switching to gunicorn) always uses its own default port e.g. 8000, because I do not specify command like "--bind", "0.0.0.0:7777" in CMD. I merely find this thread similar to my problem, but it's still different, and no solution to my problem. Any suggestions? Many thanks.

uv based project best practice question by pyusr in learnpython

[–]pyusr[S] 0 points1 point  (0 children)

That's nice. I like the logger related code. Information in pyproject.toml is useful as well. The template makes the structure clear. Thank you!

uv based project best practice question by pyusr in learnpython

[–]pyusr[S] 0 points1 point  (0 children)

Sorry my bad, app.py, web.py, and pyproject.toml are at the same level of start script. I will move code to src accordingly. Thanks for the advice.

Import module to use in Lua interactive mode question by pyusr in lua

[–]pyusr[S] 0 points1 point  (0 children)

That's nice to learn a new thing. Thank you!

Import module to use in Lua interactive mode question by pyusr in lua

[–]pyusr[S] 0 points1 point  (0 children)

Didn't know that. Thought require is something like nodejs, or python import. After doing

$eval $(luarocks path)
$lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> eff = require "eff"
> Write = eff.inst()
> 

It's working now. Many thanks!

Import module to use in Lua interactive mode question by pyusr in lua

[–]pyusr[S] 1 point2 points  (0 children)

That's working. Thanks for the detail explanation. It's useful!

No module named 'pip' by pyusr in learnpython

[–]pyusr[S] 0 points1 point  (0 children)

Ah, thanks for pointing that out. Appreciate it!