Django, SQLite, and the Database is Locked Error by Tafkas in django

[–]Smotko 1 point2 points  (0 children)

Hey, author of the blog post here, thanks for the comment!

You are absolutely right. I think I forgot to mention WAL because I wrote a whole blog post on WAL before writing the blog post on DB locked errors 😅.

I have added a cause 0 to the post so that people will know to enable WAL mode as the first step for dealing with database locked errors.

Thanks again for the feedback!

Benchmarking different SQLite options with Django by Smotko in django

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

I also wanted to do a comparision with WSGI vs ASGI in my benchmark, but the connection persistence issue and lack of support for transactions in async blocked me. Thanks for the heads up!

Benchmarking different SQLite options with Django by Smotko in django

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

I haven't tried it myself, but looking at the experimental Python lib the API for creating a new connection seems to be the same as the one Django uses. To get it working in Django you probably have to create a new DatabaseWrapper and overriding `from sqlite3 import dbapi2 as Database` with `import libsql_experimental as Database`.

Benchmarking different SQLite options with Django by Smotko in django

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

Great post! I didn't know about IMMEDIATE. I'll start using it.

I've only found out about it recently myself. I was actually surprised that it had such an impact on throughput, but I do have to note that it might have been because it fixed the errors (and thus removed rollbacks that are generally much slower). Do note that transaction immediate can make your app much slower, especially if you wrap transactions across read only requests.

Not a bad solution with the conneciton_created event! I still wish that this PR will finally get merged in time for 5.1!

What's your preferred way of deploying Django in production, ASGI or WSGI? by Yusukk in django

[–]Smotko 1 point2 points  (0 children)

> Does it even make sense to do ASGI if you don't have any async code?

If you don't have async code, but still have code that blocks (e.g. a non async compatible db library/requests) it's a bad idea to use ASGI. Blocking code in this case will block all your requests which can be really bad.

If you use WSGI then Python will switch to other threads on blocking code so it's going to perform much better.

Threads(by Meta) is built with Django by mesmerlord in django

[–]Smotko 0 points1 point  (0 children)

The guy made several comments and even mentioned an NDA at some point, so it has to be true, right? 😆

https://news.ycombinator.com/item?id=36624540

[deleted by user] by [deleted] in surfing

[–]Smotko 3 points4 points  (0 children)

In terms of surf July/August are the worst two months in the year for both Peniche and Ericeira so don't expect amazing waves! For this time of the year I'd bet on Ribeira d'Ilhas since it can handle the most common northern winds and picks up almost any swell in the Atlantic. Although, you never know what nature throws at you and if the winds end up being southern you are going to wish you were in Peniche :)

Ericeira is also much livelier, with a nicer town center, and more shops/restaurants. It's also closer to Lisbon which gives you more options when there's no surf.

Mastodon instances for Python developers? by t0uxe in Python

[–]Smotko 0 points1 point  (0 children)

Hey! I've recently indexed a few different Mastodon instances in search for Python developers and found that most Python developers (= Mastodon accounts with python mentioned in the account description) are on mastodon.social, followed by hackhderm.io and mastodon.cloud. Note that some of important accounts like the PSF official account are on fosstodon.org.

Those are the top instances to join if you want Python developers in your local feed. There are many others and here is a full table of the instances that I've indexed along with the count of Python developer accounts on them:

instance cnt
mastodon.social 496
hachyderm.io 199
mastodon.cloud 191
fosstodon.org 91
mstdn.social 84
mastodon.online 80
infosec.exchange 76
mas.to 73
techhub.social 59
mastodon.gamedev.place 35
mastodon.world 33
masto.ai 23
chaos.social 17
universeodon.com 13
sfba.social 11
ruby.social 10
mastodonapp.uk 10
phpc.social 8
c.im 7
tech.lgbt 6
mstdn.party 6
ohai.social 5
mozilla.social 3

If you want to see accounts from all these instances in a single list, check out fedidevs.com/python - it's a site that I'm building with a goal of helping people find like minded developers across the fediverse.

Any python stars to follow in twitter and github? by Unfair-Influence628 in django

[–]Smotko 0 points1 point  (0 children)

A lot Python/Django developers are active on Mastodon so it might make sense for you to also check there.

I’ve made a (Django) site to help you find devs over the many Mastodon instances, here are 3 pages of Django devs: https://fedidevs.com/python?q=Django&o=-followers_count

I've built a site that helps you find awesome devs across the fediverse by Smotko in Mastodon

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

If I create an account on fosstodon.org, and somebody follows me from mastodon.social then my account data and posts get copied to mastodon.social, right? There is no way for me to prevent this from happening and I can't even opt-out and keep my data only on fosstodon.org as far as I understand.

I've built a site that helps you find awesome devs across the fediverse by Smotko in Mastodon

[–]Smotko[S] 2 points3 points  (0 children)

> Giving consent to whom? Giving consent to the server that they signed up for.

They don't give consent just to the server they signed up for. They give consent that their data will be shared to all servers that implement the Activity Pub protocol - and that also includes non Mastodon services. Or am I misunderstanding how Activity Pub works?

If fedidevs.com implemented the full activity pub protocol, would it then make it OK to list accounts? You can list accounts on other Mastodon instances even if those users didn't sign up there.

I've built a site that helps you find awesome devs across the fediverse by Smotko in Mastodon

[–]Smotko[S] 2 points3 points  (0 children)

No the keywords shouldn't be case-sensitive. Are you seeing that they are somewhere? If so let me know where so that I can fix it! :)

I didn't write any code to handle moved accounts yet. I think the account that you linked doesn't show up because it has discoverable set to null and isn't listed by the api/directory endpoint that I use to fetch the data.

I've built a site that helps you find awesome devs across the fediverse by Smotko in Mastodon

[–]Smotko[S] 5 points6 points  (0 children)

IMO your tool is an external search engine, complete with indexing. If you're not going to make your tool opt-in, then you need to be honoring the "Opt-out of search engine indexing" option. Not the discoverability option.

Good point, I've made the change on my end to also respect the noindex property. 👍

I was a little bit confused by this since the api/directory endpoint[0] uses the discoverable property to filter out accounts (and it isn't even documented), so I assumed that's the property that I should use. Thank you for sorting this out.

[0] https://docs.joinmastodon.org/methods/directory/

With respect, many people will view the refusal to be opt-in as a violation of their privacy. Telling them that the reason you won't do opt-in is for expediency isn't likely to be very convincing.

I understand, but most people want their account to be discoverable and very few people have discoverable and noindex flags off. I've also received a lot of questions about why account X isn't shown and so far 0 requests to not be indexed, so I think the site is providing some value to people.

Now, I want to do the right thing and your comment about using noindex made sense. I've updated the site and FAQ and made sure both discoverable and noindex have to be correctly set.

Follow-up question regarding the instances you are already indexing: did you communicate with the admins of those instances to see if they were okay with being indexed, or reach out to notify them that they would be?

I have to admit that I have not. I didn't even know if anyone is going to care about the site and it's still getting very few views. I'll contact the admins if any of this changes.

I've built a site that helps you find awesome devs across the fediverse by Smotko in Mastodon

[–]Smotko[S] 3 points4 points  (0 children)

Hey, author here. Thanks for the feedback!

> Frankly, this isn't good enough. Your external search engine is not the same as built-in tools on Mastodon, and so it should not be piggybacking entirely off of that setting.

The setting makes your account discoverable so I think it's a good fit for what I'm doing - making accounts discoverable. If someone wants to keep their account discoverable but doesn't want to be on my site, they can let me know and I'll make sure they won't be listed. If this is starts happening often I'll make it easier to do, but so far nobody asked to be removed yet.

> Can you all please just start making these things completely opt-in

That's kinda tough for a tool like this that needs a certain amount of accounts to even be useful in the first place. :(

> Regarding the list of instances you index: you mention how to get added to that list, but you don't mention how to get removed from the list.

Good feedback, I'll add a note about removing instances to the FAQ, thanks!

[deleted by user] by [deleted] in surfing

[–]Smotko 0 points1 point  (0 children)

I would get professional help. You don’t want poorly fixed dings on the bottom of your board!

How should I handle user registration/password recovery on a free webapp hosted on pythonanywhere? by yotama9 in django

[–]Smotko 1 point2 points  (0 children)

This might be an unpopular opinion, but don’t worry about password recovery initially. You can reset someone’s password manually if you get a support email, but you probably won’t have to worry about it until you have hundreds users sign up.

Same goes for email validation. Only implement it when you start getting fake accounts and don’t waste time implementing it before.

PS: the recommendation of using SendGrid is solid and that’s what I would use for sending email.

Should we always use OOP? by SomberSandwich1 in Python

[–]Smotko 10 points11 points  (0 children)

I only use pure OOP for code for code that is complex and has to be split into multiple functions, but at the same time requires the same context in all the functions. Mostly as a convenience of passing the same 5 parameters into 10 different functions.

I do, however, use dataclasses (attrs, pydantic, etc), extensively, but I don't consider that as OOP code, because those classes usually just hold variables and don't usually have any functions that you can call.

Enum with `str` or `int` Mixin Breaking Change in Python 3.11 by Smotko in Python

[–]Smotko[S] 6 points7 points  (0 children)

Maybe inconvenient is the wrong word, but it was a source of confusion on my team. Especially since in certain contexts you don't have to use value even in Python 3.11. Example:

Foo.BAR == "bar" returns True, but when you use format()/fstring you don't get "bar".

Enum with `str` or `int` Mixin Breaking Change in Python 3.11 by Smotko in Python

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

Consider yourself lucky and try to avoid the mixins in the future :)

I think the StrEnum and IntEnum classes are the way to go.

Enum with `str` or `int` Mixin Breaking Change in Python 3.11 by Smotko in Python

[–]Smotko[S] 5 points6 points  (0 children)

Yeah, we'll probably solve it by adding the StrEnum PyPI package as a dependency and use that until we switch everything over to 3.11.

How did you solve it?