## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Mar 14 2020 19:42
florimondmanca closed #334
• Mar 14 2020 19:41
florimondmanca commented #334
• Mar 14 2020 19:39

florimondmanca on pip

• Mar 14 2020 19:39
dependabot-preview[bot] commented #342
• Mar 14 2020 19:39
florimondmanca closed #342
• Mar 14 2020 02:00

dependabot[bot] on npm_and_yarn

• Mar 14 2020 02:00
dependabot[bot] commented #343
• Mar 14 2020 02:00
florimondmanca closed #343
• Mar 13 2020 23:34
codecov-io commented #343
• Mar 13 2020 23:33
codecov-io commented #343
• Mar 13 2020 23:32
codecov-io commented #343
• Mar 13 2020 23:29
dependabot[bot] labeled #343
• Mar 13 2020 23:29
dependabot[bot] opened #343
• Mar 13 2020 23:29

dependabot[bot] on npm_and_yarn

Bump acorn from 6.1.1 to 6.4.1 … (compare)

• Mar 09 2020 05:28
codecov-io commented #342
• Mar 09 2020 05:28
florimondmanca commented #342
• Mar 09 2020 05:27
codecov-io commented #342
• Mar 09 2020 05:26
codecov-io commented #342
• Mar 09 2020 05:23
dependabot-preview[bot] labeled #342
• Mar 09 2020 05:23
dependabot-preview[bot] opened #342
Florimond Manca
@florimondmanca
@alfredchiesa Coming back to your question on larger project structures last time, you may want to check out the new Bocadillo CLI and fiddle around with the create command, it should give you an example of a full-featured project file structure: https://github.com/bocadilloproject/bocadillo-cli
We’re still working towards being able to easily split an app into multiple files :)
^For example via #261
EricE
@EricE
Thanks for the update! For truly CPU bound applications, wouldn't you want to use ProcessPoolExecutor instead of ThreadPoolExecutor (unfortunately not in starlette)? Seems like you would slow down your asyncio app using the ThreadPoolExecutor but have minimal impact with ProcessPoolExecutor. I know it can be more limiting to work with Processes over Threads (pickling) but for maximum speed using ThreadPoolExecutor seems better.
Florimond Manca
@florimondmanca
Yes, I’ve heard that deferring highly CPU-bound operations to a process is more effective in Python. @EricE Maybe you should open a PR to Starlette to add run_in_processpool()? ;)
EricE
@EricE
If I only knew how to use Github :) I just downloaded their desktop app, I'll see if I can figure it out. The hardware guys at my company still use SVN for our FPGA files, etc., and I use it for my Python projects. Our SW guys are switching to Git and it is clearly the winner so time to switch...
Florimond Manca
@florimondmanca
Ah right, you’re into hardware! This website helped me a lot when starting with git two years ago :) http://rogerdudler.github.io/git-guide/
Ilyes Bouchlaghem
@Ibouch
Hi ! I am reading about ASGI servers more precisely on Uvicorn and a framework using it (Starlette.io). It turns out that in their section 'Third Party Packages' they quote you with another framework (FastAPI), so Bocadillo is a framework of another framework? Would not this add unnecessary overlays rather than contribute directly to the Starlette.io project?
Anyway good job, there are features that look cool
Florimond Manca
@florimondmanca

Hi Ilyes! Thanks for pitching in, this is an interesting question!

Actually, Bocadillo uses Starlette as an ASGI toolkit, not as a framework. For example, we reuse Starlette’s HTTP request representation (the Request class), as well as various ASGI middleware classes (eg the CORS middleware) and some other features (eg background tasks). But Bocadillo has a different design for views, and other features completely separate from Starlette (eg dependency injection). This hasn’t happened yet, but I’d be very much keen to bring generic enough features back into Starlette (in fact, I am personally a contributor to Starlette and uvicorn). :)

OTOH, it is true that FastAPI can be seen as a framework of a framework. For example, its app class is a direct subclass of ‘Starlette’ class. I think tiangolo is involved in both Starlette and uvicorn as well though.

Ilyes Bouchlaghem
@Ibouch
Ok thank you for the precision, in the description of your project, would you know what 'asynchronous salsa means?
Florimond Manca
@florimondmanca
Bocadillo means sandwich in Spanish, and salsa means sauce, so it’s just a pun for the fact that Bocadillo is an async framework :)
Ilyes Bouchlaghem
@Ibouch
hm ok, because I had found on the internet "Salsa: A Framework for Scalable Asynchronous Replica Exchange"
but it did not make sense
Florimond Manca
@florimondmanca
Oh, right. Yeah, Bocadillo has nothing to do with this paper. 😅 I can see that’s what I get as a second result when googling for “asynchronous salsa” as well.
Ilyes Bouchlaghem
@Ibouch
I chose to use starlette.io, but I may reconsider my choice if I realize that bocadillo saves me development time and does not affect performance. This is for a web application of a large community and the current version under Flask (and Flask-SocketIO for websocket), does not support the load.
If I use bocadillo, I will mention to my community (video games so also some devs) to increase the visibility of your project!
Florimond Manca
@florimondmanca
Sounds good! Good luck with your project 👍
Ilyes Bouchlaghem
@Ibouch
Thank you :)
EricE
@EricE
I'm wondering is something is off with the demo file structure? I ran bocadillo create demo and got
+---demo
¦   +---demo
¦   ¦   +---app.py
¦   ¦   +---asgi.py
¦   ¦   +---providerconf.py
¦   ¦   +---settings.py
¦   ¦   +---__init__.py
¦   +---templates
(I added templates). From the tutorial it seems like templates should be in the same subdirectory as app.py but jinja2 throws an error if it is
I run uvicorn demo.asgi:app --reload in the first demo subdirectory
EricE
@EricE
If I run uvicorn asgi:app --reload in the second demo subdirectory, it errors:
(D:\SVNRepo\projects-sw\async_web\trunk\env) D:\SVNRepo\projects-sw\async_web\tr
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Process SpawnProcess-1:
Traceback (most recent call last):
File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\multiprocessing\process.p
y", line 297, in _bootstrap
self.run()
File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\multiprocessing\process.p
y", line 99, in run
self._target(*self._args, **self._kwargs)
File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\mai
n.py", line 305, in run
loop.run_until_complete(self.serve(sockets=sockets))
File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\asyncio\base_events.py",
line 584, in run_until_complete
return future.result()
File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\mai
n.py", line 312, in serve
File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\con
File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\imp
orter.py", line 23, in import_from_string
raise exc from None
File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\imp
orter.py", line 20, in import_from_string
module = importlib.import_module(module_str)
File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\importlib\__init__.py", l
ine 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File ".\asgi.py", line 3, in <module>
from .app import app
ImportError: attempted relative import with no known parent package
INFO: Stopping reloader process [18712]
Florimond Manca
@florimondmanca

From the tutorial it seems like templates should be in the same subdirectory as app.py but jinja2 throws an error if it is

The docs say that it should be placed in the same directory relative to where the app is run (ie using uvicorn), so that means the location you put it at should work. Doesn’t it?

If I run uvicorn asgi:app --reload in the second demo subdirectory, it errors:

Yes, that is expected, because the generated demo package uses relative imports, which you can’t use in Python unless you’re running from outside of that package. We should probably add a warning/caveat in the docs

EricE
@EricE
It did work when I put the templates directory as I showed in the directory tree listing above. However, in the templates guide it looks different:
shows the templates directory at the same level as app.py. However, app.py is created in the second demo subdirectory and when I tried running there it caused the above error. So I was able to make it work but it seems inconsistent with the documentation.
EricE
@EricE
Florimond Manca
@florimondmanca
Yes, I see. This is because the example app there doesn’t use a project generated with Bocadillo CLI. The templates dir location really is irrelevant or where app.py is. It really is just ./templates, with . meaning the current directory.
Could you track this in an issue, please? I’ll have a look when I have some time. Or if you feel like it you can propose a clearer wording. :-)
Florimond Manca
@florimondmanca
@EricE I opened #276 :+1:
Zuhair
@florimondmanca
Florimond Manca
@florimondmanca
Hi @zowhair_twitter :-) DB support is not built-in, but you should find useful info here: https://bocadilloproject.github.io/discussions/databases.html
Zuhair
Thanks bro, and cli tool you used is click??
Florimond Manca
@florimondmanca
Yup, Bocadillo CLI is built on top of Click
Zuhair
i see..
Florimond Manca
@florimondmanca

Hi peeps, just to let you know that I am planning to close this Gitter chat soon.

The experience I’ve had is that most of the discussions taking place here would benefit from being out there in the open (ie in GitHub issues), indexed, searchable and actionable.

Also, while I enjoy answering questions, the chat or DM system here has been taking up on my attention, and it would be much easier to manage via issues.

So I invite everyone to start using issues for questions (even simple ones!), since this chat should be closed by next week. 👍 Thanks!

Marwan Rabbâa
@waghanza
Hi, could a route be constrained (accept only digits for example) by any regexp or else ?
Florimond Manca
@florimondmanca
Hi @waghanza, I don’t think regex validation is supported atm. I think it’s an interesting topic though, could you open an issue as I mentioned in my last post?
Also realizing that I didn’t actually close this chat 😄 actually my thought is that Gitter may not be the best solution for community gathering and chatter. Haven’t got much time to dedicate to this recently unfortunately. Will open an issue to track what’s to be done / what questions need to be discussed
Marwan Rabbâa
@waghanza
@florimondmanca perhaps slack could be a suitable alternative
Florimond Manca
@florimondmanca
Yes, I’ve been thinking about Slack — I know a few communities that use it (Masonite, Tartiflette), but the fact that workspaces are private bugs me (not searchable, not indexable, etc). I’ve also heard about Spectrum, do you know about it / have any opinion on it? :)
Marwan Rabbâa
@waghanza
have heard of it, but now used. I like slack because of ecosystem + mobile app, and I've also heard of https://twist.com which is a slack alternative
I'm not keen on discord`
EricE
@EricE
Greetings, I couldn't bring myself to post this as an issue :) I chatted with you previously about using Bocadillo to create a site that would replace a desktop app. I need to do hundreds/thousands of REST queries, database accesses, crunch numbers and generate various UIs. As you might recall I am a hardware guy and still learning web dev stuff. It seems like a lot of the async web frameworks are oriented towards being a site that responds to API requests vs being a consumer of them? Does this sound like an appropriate use of Starlette or should I just stay with something like Flask and Celery?
Florimond Manca
@florimondmanca
Hey @EricE! Sure, let’s chat here. :) Oh and for anyone concerned Bocadillo just entered unmaintained state - as announced at the beginning of October eg in #334.
So, if your use case is to make HTTP requests rather than respond to them, it seems you’re looking for an HTTP client rather than a web framework (which help at building servers).
If that’s the case you might be interested in checking our HTTPX: https://github.com/encode/httpx, which is basically a more modern version of Requests, in particular with async support.
My guess is you can use HTTPX to make API calls, a library like databases (https://github.com/encode/databases) for async database access, and if you need to serve some web pages on top then you can definitely look into Starlette