New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PicklingError on Ubuntu #79
Comments
Hi ! same here using hypercorn 0.14.3 for fastapi - debian docker image - python 3.10.4-slim-bullseye
In my case the problem is located in my base docker image, derived from https://github.com/bynect/hypercorn-fastapi-docker - in particular the hypercorn.py file : https://github.com/bynect/hypercorn-fastapi-docker/blob/main/images/hypercorn_conf.py it's certainly a side effet of the new 0.14 release. |
In order to patch this problem, I remove from the |
That would make sense, the config is sent to the processes by being pickled. @ThomasChiroux do you also customise the config? |
yes, my configuration file is almost exactly like this one: https://github.com/bynect/hypercorn-fastapi-docker/blob/main/images/hypercorn_conf.py which is used here: https://github.com/bynect/hypercorn-fastapi-docker/blob/main/images/start.sh the conf file is a .py file like this pseudo code below:
($HYPERCORN_CONF == hypercorn_conf.py) hyperconf.py uses a custom method to map bools from env: def booleanize(value) -> bool:
if value is None:
return False
falsy = ["no", "n", "0", "false"]
truly = ["yes", "y", "1", "true"]
if value.lower() in falsy:
return False
elif value.lower() in truly:
return True
else:
raise TypeError("Non boolean-like value {}".format(value))
#ssl opts
use_ssl = booleanize(os.getenv("USE_SSL", "False")) (the method booleanize is the one not serializable) then at the end of the .py file after setting all the variables the conf is outputed for hypercorn: conf_data = {
"accesslog": accesslog,
"errorlog": errorlog,
"loglevel": loglevel,
"backlog": backlog,
"bind": bind,
"insecure_bind": insecure_bind if use_tcp and use_ssl else None,
"quic_bind": quic_bind if use_quic_bind else None,
"graceful_timeout": graceful_timeout,
"keep_alive_timeout": keep_alive_timeout,
"workers": workers,
"worker_class": worker_class,
"env": {
"host": host,
"ssl_port": ssl_port if use_ssl else None,
"tcp_port": tcp_port if use_tcp else None,
"use_ssl": use_ssl,
"use_tcp": use_tcp,
"workers_multiplier": workers_multiplier,
"cores": cores
}
}
print(json.dumps(conf_data, indent = 4), flush = True) |
@ThomasChiroux Can you try to move the function |
I managed to make it work by removing booleanize entirely. It was not widely used in the module. I'm now testing the new image with the last hypercorn, seems ok thks. |
I've tried to make the error clearer in 4645aa0. |
The text was updated successfully, but these errors were encountered: