Closed xxxxxxbox closed 6 months ago
Hi, interesting, that class is defined in that extension module. Could you please share more details about your setup, so I can try to reproduce the error?
Hi. Thank you for reply.
This problem was due to misconfiguration.
BlackSheep was installed in docker like this:
Dockerfile:
RUN pip install Cython && git clone https://github.com/Neoteroi/BlackSheep.git \
&& cd BlackSheep && make compile && python3 setup.py install \
&& pip uninstall rodi
requirements.txt:
rodi @ git+https://github.com/la5tway/rodi.git@add_async_providers
Due to this instructions latest version of Blacksheep was installed. At time of run it was v2.08a with rodi v2.0.2/ Then rodi was uninstalled and reinstalled by line in requirements.txt with forked version 2.0.0. from https://github.com/la5tway/rodi/tree/add_async_providers
To fix the error I had to select in Dockerfile the latest version of BlackSheep v2.0a4 that supports Rodi v2.0.0. I had to alter Dockerfile like this:
RUN pip install Cython && git clone https://github.com/Neoteroi/BlackSheep.git \
&& cd BlackSheep && git checkout tags/v2.0a4 \
&& make compile && python3 setup.py install \
&& pip uninstall rodi -y
Although the Error was fixed I'm in another situation.
I had to maintain and develop several existing projects that use BlackSheep with custom version of Rodi from https://github.com/la5tway/rodi/tree/add_async_providers I can't use regular version of rodi and it seems that the custom version of rodi is not going to be updated in the future. So, all my projects stuck for the time being with the latest version of BlackSheep I can use (v2.0a4).
Hey @RobertoPrevato, is there any reason that async providers are not part of rodi/Blacksheep? I finally found a framework/lib that actually does DI (in contrast to fastapi/litestar), but the lack of ability to handle async/async with here is a real bummer.
Hi @rafales
The reason why I didn't include async providers in rodi is because I always thought of dependency injection like something that is supposed to run fast and synchronously, in the same way you don't have built-in support for async __init__
in Python. It is the same in TypeScript or C# and I guess in most programming languages: you don´t have async constructors. DI for me was always something related to constructors.
But I appreciate your feedback, you are not the first one asking about this feature. I am considering to look into this.
By the way, BlackSheep supports injecting objects that require asynchronous initialization, but expects configuring them in the application start event, like described here: Services that require asynchronous initialization and here Using the lifespan decorator.
PS. your comment is off topic under this issue, would be worth putting it in a discussion.
Closing as the original issue was resolved.
Sometimes I get an error due to wrong server configuration when trying to run multiple containers with Docker. In traceback in logs I can not see the real reason of error, but messege bellow. Please check blacksheep.exceptions file for attribute 'MessageAborted.
file "/usr/local/lib/python3.11/site-packages/blacksheep-2.0a8-py3.11-linux-x86_64.egg/blacksheep/init.py", line 8, in
File "/usr/local/lib/python3.11/site-packages/blacksheep-2.0a8-py3.11-linux-x86_64.egg/blacksheep/contents.py", line 9, in
File "/usr/local/lib/python3.11/site-packages/blacksheep-2.0a8-py3.11-linux-x86_64.egg/blacksheep/contents.py", line 8, in bootstrap
File "blacksheep/contents.pyx", line 1, in init blacksheep.contents
AttributeError: module 'blacksheep.exceptions' has no attribute 'MessageAborted'