Skip to content
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

💡 Use trio in this project #3

Open
Mariatta opened this issue Aug 13, 2019 · 4 comments
Open

💡 Use trio in this project #3

Mariatta opened this issue Aug 13, 2019 · 4 comments

Comments

@Mariatta
Copy link
Member

It would be great to use Trio to build the bot for Trio.

@njsmith
Copy link
Collaborator

njsmith commented Aug 13, 2019

I was curious how hard this would be. From a quick skim:

  • right now it's using feedparser to fetch the feed. That's a blocking operation.
  • then it uses aiohttp to make the POST to the gitter API
  • it also uses APScheduler in asyncio mode to implement the "every ten minutes" loop

Given a trio http client we like, it would be trivial to replace the use of aiohttp. APScheduler doesn't have trio support, but for the way we're using it here we could replace it with a few lines of code. Feedparser is more of an issue – maybe there's some way we could fetch the RSS ourselves then just ask feedparser to parse it?

It's not clear to me whether any of this would be useful though :-). The not never does anything concurrently, so there's actually no reason to use async/await at all...

@sorcio
Copy link

sorcio commented Aug 15, 2019

I think this could be more for fun than for a serious reason :) The bot code as I see it could be fully synchronous at this time, so maybe it doesn't matter at all. Also if people look up "trio gitter bot" they would find this project!

One way concurrent code could maybe be useful is if you want to save something on hosting and run multiple i/o-centric bots like this one in a single Heroku container? That's a stretch just to include some more compelling reason to care about this. Or maybe you want a web interface to monitor the bot.

@njsmith
Copy link
Collaborator

njsmith commented Aug 16, 2019

if people look up "trio gitter bot" they would find this project!

Oh, that might be a bit annoying yeah. Don't want to anti-SEO ourselves...

Umm. In other news, I might have accidentally made a trio-compatible library for writing github apps?

Super experimental and all that but if someone's looking for an excuse to use trio to manage trio then this might be a more interesting place to start.

@njsmith
Copy link
Collaborator

njsmith commented Aug 20, 2019

One way concurrent code could maybe be useful is if you want to save something on hosting and run multiple i/o-centric bots like this one in a single Heroku container?

I thought the github bot would be able to get away with heroku's free tier, but I just noticed that webhook deliveries were timing out on a fairly regular basis, so I had to bump it up to the paid tier. So now I'm paying $7/mo twice, once for the gitter bot and once for the github bot. This is still ... objectively not a big deal, at market rate that's equivalent to like a few minutes of programmer time per month, and it would take like a year+ to match what I spent on trio stickers for pycon. But still, it does mean this isn't just theoretical, combining the two bots would directly save money.

There might also be neat things we can do by having access to the gitter and github APIs in the same app? And the github bot already has postgres set up, which would make it pretty easy to make the gitter bot more reliable (#4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants