#dev-contrib
1 messages · Page 121 of 1
explain.
That's the whole point
lmao
You had that coming
.wa short define
determine the essential quality of
very nice
That's too much effort
Wolfram has everything
Look I'll gladly write it all if y'all don't want to
There is a side to contributing that’s often forgotten. Writing code is usually the smallest part, the rest is in review and maintenance.
If you’d like to get discussion on this, feel free to open an issue on the repo
Where would you get the definitions from?
Though it feels redundant given wolfram
Either an api or just webscrape it from dictionary.com
the bot doesn't really need yet another module that would just expose some web api
@vocal wolf I want to make an issue for an .epoch commands, which given a date/time or a duration (i.e. 40M (from now)) will spit back out the unix/epoch time to use the discord timestamp feature. Would that be lancebot?
that would be lancebot indeed
yes
lmao
I am not
Xitha bot, therefore I don't know specific epoch times off the top of my head.
well yes of course the current time is about1626461022.831569
so
as far as I can see
multiple processes in snekbox is not harmful from a killing pov
they do seem to get killed off
I just need to check how memory limits are applied, if it's one per child proc it complicates things
Mmmmm I remember issues I found with child procs, but never really tried them
Will have to look into it
We probably also want to mount everything but the python binary in noexec
can someone give me an example of epooch?
are you asking what epoch time is?
umm..kinda
it's another name for Unix time, which is the number of seconds since the new year started in 1970 in UTC
it's a handy way for computers to represent a particular time without ambiguity
ohh now i get it
so..kutiekat is saying to change this epooch time to standard time right?
what she wants is a command that gives you the epoch time for a given date-time
it's not super simple though, because the date-time is relative to a timezone, so you'd need to know the timezone to calculate the epoch time
wdym
!e
Why not:
from datetime import datetime
print(datetime.utcnow().timestamp())```
@cold island :white_check_mark: Your eval job has completed with return code 0.
1626481471.142881
ohk cool i want to try this
so @cold island the dateandtime is given by the user right?
yes
Kat wants the command to work for a given datetime, not just right now
You can look at examples in the bot on how we usually accept such an argument
okay cool i will make it
The converter takes care of that I believe
Hmm actually
It handles durations and UTC datetimes
Why not just assume UTC?
iOS got support
iOS mobile? A few days ago it didn't
i am guessing he is from india
France actually, but that's off topic
Ohh
The timestamps seem to work on iOS mobile as well
How do you do that? Is it automatic?
July 20, 2021 08:42 PM
There's some specific format for it
I'm not sure what exactly, just remember it sorta looks like what you get doing \:emoji:
Ah
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
can confirm timestamps work on iphone now
Hmm, not seeing updates on the store or anything
probably gradual roll out
@tough imp @gritty wind what ios version and app versions
<t:unix>
latest and latest
14.6 & 80.0 I think
That seems to be latest on the store, not sure why I’m not getting an update in that case
Alright, feel free to push forward in that case
Pushing an update to apple/google stores don't hit all regions at the same time
I've found it can take >a week sometimes for apps in multiple countries
Timestamps are rolled out everywhere? 
wow how do u guys get so advance ?
I mean..until I saw this bots code i didnt knew there were these many methods and functions 🤯just mind blown lol
Haha, reading source code is a very good way to learn some specific tricks
Most of the code is also decoupled so it's not as hard as it looks at first glance
If you are taking about the docs code then you are probably right, pokenmonmaster
Whats the reason for putting python-dotenv = "~=0.17.1" in dev deps in bot?
in prod we don't use dotenv
ah ok
prod env vars are injected by k8s (through docker env vars)
If it hasn't reached all regions yet then we shouldn't hurry to merge it
Yep, we will see when it is ready to merge if it has been rolled to every region
It will probably take more time for us to review than for the store to roll out, or we can wait once it is ready
@tawdry vapor @glacial veldt investigating multiprocs on snekbox, limits are certainly shared somehow, my test script is ```py
import os
from multiprocessing import Process
items = [1, 2, 3, 4]
def func(item):
a = "A" * 30_000_000
print(f"PID: {os.getpid()} - Processing: {item}")
if name == 'main':
procs = []
for item in items:
p = Process(target=func, args=(item,))
p.start()
procs.append(p)
for proc in procs:
proc.join()
for proc in procs:
print(proc.exitcode)
killing is a little bit inconsistent, with the same limits sometimes one gets killed, sometimes two, etc.
testing how zombies are handled now
as far as I can see, things do get killed
Now my question is can you spawn a thread under another CGroup
As in running a process in one !e consumes a resource from all other concurrent !e calls?
uhhh
Nah, we create a new cgroup for each eval
child procs shouldn't be able to spawn into a different cgroup
Bear in mind that I don't know much about cgroups
But iirc fork() gives you the option of selecting a new cgroup?
Will that mean you have two cgroups under one process
forked procs by default are going into the same cgroup ```
root@snekbox_dev:/Users/joseph/Desktop/Python/snekbox# cat /sys/fs/cgroup/memory/snekbox-040de838-6259-4414-abc6-a2c61e27d8a8/NSJAIL.57/tasks
57
60
fork does not give you any options
a process shouldn't be able to rehome itself in the pids or memory cgroups because we don't mount /sys/
okay — as far as I can see multiple processes seems to be safe within snekbox, so I'm going to open a PR to bump max PIDs to 5
updating some tests now
this is my revised unavailable test ```py
def test_subprocess_resource_unavailable(self):
code = dedent("""
import subprocess
# Max PIDs is 5.
for _ in range(6):
print(subprocess.Popen(
[
'/usr/local/bin/python3',
'-c',
'import time; time.sleep(1)'
],
).pid)
""").strip()
result = self.nsjail.python3(code)
self.assertEqual(result.returncode, 1)
self.assertIn("Resource temporarily unavailable", result.stdout)
self.assertEqual(result.stderr, None)
Looks good
@tawdry vapor I believe this tests multiproc resource limit sharing, just asserting that one of the child processes is SIGKILL'd ```py
def test_multiprocess_resource_limits(self):
code = dedent("""
import time
from multiprocessing import Process
def f():
object = "A" * 40_000_000
time.sleep(0.5)
proc_1 = Process(target=f)
proc_2 = Process(target=f)
proc_1.start()
proc_2.start()
proc_1.join()
proc_2.join()
print(proc_1.exitcode, proc_2.exitcode)
""")
result = self.nsjail.python3(code)
exit_codes = result.stdout.strip().split()
self.assertIn("-9", exit_codes)
self.assertEqual(result.stderr, None)
will commit now
Yeah looks good enough
pushed
!eval ```py
from multiprocessing import Process
def f():
print("1234")
proc_1 = Process(target=f)
proc_2 = Process(target=f)
proc_1.start()
proc_2.start()
proc_1.join()
proc_2.join()
print(proc_1.exitcode, proc_2.exitcode)
@patent pivot :white_check_mark: Your eval job has completed with return code 0.
001 | 1234
002 | 1234
003 | 0 0
Nice tyvm
Ohh 1st trick
Mhmm for some people like experienced
I mean the source codes
I mean, the files themselves are easier to understand, but the bot as a whole is not as complicated as it may seem from the amount of code it has because the features more often than not don't interact with other code. But there are some features which are complicated and need to use things like scheduling
!e
import anyio.to_thread
async def amain():
await anyio.to_thread.run_sync(print, "hello")
anyio.run(amain, backend="trio")
@glacial veldt :white_check_mark: Your eval job has completed with return code 0.
hello
embarrassing xD
Thanks muchly!
!e
I wonder what happens if I use too many threads?
import anyio.to_thread
import time
async def amain():
async with anyio.create_task_group() as tg:
for i in range(6):
tg.start_soon(anyio.to_thread.run_sync, time.sleep, 3)
anyio.run(amain, backend="trio")
@glacial veldt :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 9, in <module>
003 | File "/snekbox/user_base/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 56, in run
004 | return asynclib.run(func, *args, **backend_options) # type: ignore
005 | File "/snekbox/user_base/lib/python3.9/site-packages/trio/_core/_run.py", line 1932, in run
006 | raise runner.main_task_outcome.error
007 | File "<string>", line 7, in amain
008 | File "/snekbox/user_base/lib/python3.9/site-packages/anyio/_backends/_trio.py", line 141, in __aexit__
009 | raise ExceptionGroup(exc.exceptions) from None
010 | anyio._backends._trio.ExceptionGroup: 2 exceptions were raised in the task group:
011 | ----------------------------
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/qagikodiva.txt?noredirect
Interesting
@patent pivot why use tox.ini for isort and not pyproject.toml for king arthur?
because then I can store isort & flake8 alongside one another
what is the advantage to that?
asking because I'm configuring a toolchain right now
well, when you call flake8 it is also checking with isort that imports are compliant
because I use flake8-isort
have you ever looked at using flake9 which is it a fork of a flake8 that adds pyproject.toml support?
!pypi flake9
I try not to use those wrappers that add a minor feature because then it relies on the downstream keeping up to date
also I don't think the author of that package has conducted themselves very appropriately
Sauce?
so for now, it's fine in tox.ini
the first issue? https://gitlab.com/retnikt/flake9/-/issues/1
ah
corrected, but not a great look
(can black go in tox.ini too?)
no, pyproject is the future
hm, yeah. Not a great look at all.
So if flake8 isn't going to implement it, do you think they'll ever cave or smth?
maybe? I mean they have an open issue for it, so we'll just see
ah
i need more things to add to king arthur i am going to brainstorm
think it has to be tool.isort, no idea
Describe resources would be great, pulling logs to a pastebin too
yea
Oh events would be nice too
yeah I'm considering loading events into loki
mhm..true some bots source code are fairly easy to understand some are kinda complicated
what does snekbox do?
snekbox is our evaluation application
when you run eval snippets with !eval
we don't want to run snippets on our bot because obviously that's dangerous, so we use snekbox which isolates user code safely and executes it
!e print("hello")
@patent pivot :white_check_mark: Your eval job has completed with return code 0.
hello
@rotund light
Lol didnt see that 😅
ok, so, loki is flippin awesome
the metrics you can generate with it are op af
ya
now im just annoyed that the brew formula for timescaledb is broken
been tryna test some shit
Is there any way we can run the bot without docker?
Yes, using poetry
What's loki?
Broken link
Wait that poetry command ?
remove the 6
Yup
poetry run task start
Yes you can run the bot without docker but that would make it a bit complicated making you setup postgres and site as a must, and snekbox if you want eval and redis if you want persistence across runs (it would use fakeredis if not)
it is ran on the system
Then install deps via
poetry install
This is all documented in the getting started guide
as a cluster component
Which you’ll really need if you plan to start contributing
It says to download docker
It mentions that that’s optional, and describes how to do it locally
Docker is optional
Down the docker line yeah I saw that and I ran that too but yeah obvio didnt work cause I didnt install
Just intall poetry first
Gotcha thanks
Introduction Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
System requirements Poetry requires Python 2.7 or 3.5+. It is multi-platform and the goal is to make it work equally well on Windows, Linux and OSX.
Note...
i saw you ran sirlance a while back, how did u do that without poetry
docker?
Who me ?
yes
I ran that with docker
ah
But apparently idk what's happening to my laptop
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python - this is the command
If you’ve got docker, I’d recommend you at least use it for the site
Literally pip install poetry smh
Docker in my machine atleast it's like bruh it works for the first time I install docker it works then I shut down the computer then tried to run docker bruh didnt work
Does docker desktop start?
Nope
sudo systemctl status docker.service try that, wait you are on windows, whats the alternative scal?
Sudo wont work on windows
yeah i dunno win alternative
Yeah I think so too
no i am checking if the docker service is running
Docker status or smth?
yeah
@short snow u on linux ?
yes
That's why xd
systemctl show --property ActiveState docker see this, got from so
screen flickering 👀 i don't think that is a applicatin issue, probably your screen probablem
connect it to a monitor with HDMI or whatever and verify that ^
Yup it happened before but I got to repair before
Log storage & querying
Lol at first I thought loki from marvel
Btw what's redis ?
Found while reading the website
Technically it is Loki from the Norse mythology :P
It is a very efficient key-value storage. Long story short, a beefy dictionary.
True though but yeah I knew loki from marvel then Norse
So it's used in docker things? Or just in vanilla python
Ah databases
Like mongo db ? Like they have dictornies too
I don't know much about Mongo, but I think so? Don't quote me on that though 
Hmm Mongo seems more like JSON, you can have nested types - dictionaries inside dictionaries
You can't really do that with redis
At least not natively
Can u give an example cause I was thinking about mongo style 
Sure, the gist of redis is this:
> set mykey somevalue
OK
> get mykey
"somevalue"
```Set a key, get a key
Everything being extremely fast even if you have thousands of keys
It also supports some more fancy stuff, like expirations, lists, sets..
It is one big dictionary, yes
redis is in-memory database
Cool..lol it's like a whole world inside a dictionary 😂
Haha, Redis do think like that
Are all the files in bot directory like main.py and those files for proper working of cogs and resectriction or for any other purpose?
Like we can just do the basic way load the cogs
The init and main do call a few preparation functions such as databases, redis, and other startup stuff
The cogs after that are mostly modular
All of our cogs can be loaded separately, but we always need the main files
Ooh now I get it
hi all
if people wanna see something cool
😄
Woah, that's pretty cool. Fancy new github features
We were stressing the bot a bit, should be fine now
wow l
Uhh..?
Yeah, you haven't updated the channel IDs
You have to set environment variables for them, if they are available
You don't need to change most of them
Ah alright, that makes sense
I suggested to enable charinfo command in #discord-bots channel. (The suggestion was made in #community-meta ). And was told to follow some guide. I am stuck here: https://pythondiscord.com/pages/guides/pydis-guides/contributing/installing-project-dependencies/#installing-dependencies-with-the-command-line
A guide to installing the dependencies of our projects.
I did this fork thing on github
bot/exts/utils/utils.py line 53
@in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES)```
All you need to do is update that line to channels=(Channels.bot_commands, Channels.discord_py)
As far as I can tell anyway
@viscid coral ^
(I don't actually know how to help with the contributing guide stuff)
Do you have git installed on your computer?
Yes I am pretty sure I do
How can I update it?
If you're signed in to GitHub you can do it from the website
From my own forked repo?
If you go to the top of the file there's a pencil you can use for editing (greyed out for me because I'm not logged in)
On the python-discord one - https://github.com/python-discord/bot/blob/main/bot/exts/utils/utils.py#L53
bot/exts/utils/utils.py line 53
@in_whitelist(channels=(Channels.bot_commands,), roles=STAFF_ROLES)```
Although the proper approach is to edit it locally and make sure it works
They don't have write access
So if anything it will be on their fork
Right yea true
If you'd like I can do this one and then explain what I did for next time (because I'm honestly not too sure myself) @viscid coral
I'd assume https://github.com/python-discord/bot/pulls --> "New Pull Request"
But you should probably create a new issue [basically a feature request] about this first (saying pretty much what was said in #community-meta) https://github.com/python-discord/bot/issues
Is that ok?
That's saying what the command does; I'd link it to why it needs to be allowed in #discord-bots specifically
To add rections?
Possibly lead it with "In order to add a reaction in discordpy, we need the emoji's unicode. For most emojis...."
And the lack of space before the ( bothers me lol
them( --> them (
I'd also edit the end slightly to "The best replacement for it is the !charinfo command, which currently isn't allowed in #discord-bots but I feel should be for the above reason" or something like that
To the beginning not the end
Oh lol
In order to add a reaction in discordpy, we need the emoji's unicode. For most emojis.... For most emotes/emojis we can do \:emoji: , but for some of them (such as numbers or letters) this option is not possible. The best replacement for it is the emoji unicode, which can be easily shown in charinfo command.```
For most emojis.... For most emotes/emojis we can do :emoji:
Remove the leading "For most emojis..."
And then this @viscid coral
In order to add a reaction in discordpy, we need the emoji's unicode. For most emotes/emojis we can do \:emoji: , but for some of them (such as numbers and letters) this option is not possible. The best replacement for it is the emoji unicode, which can be easily shown in charinfo command. The best replacement for it is the charinfo command, which currently isn't allowed in discord.py, but I feel should be for the above reason.```
I am not the best in English lmao
(such as numbers or letters) -> (such as numbers and letters) (or --> and)
And you have "The best replacement for it..." twice
In order to add a reaction in discordpy, we need the emoji's unicode. For most emotes/emojis we can do `\:emoji:`, but for some of them (such as numbers and letters) this option is not possible. The best replacement for it is the `!charinfo` command, which currently isn't allowed in discord.py, but I feel should be for the above reason.
Yeah ok
👀 Just open the issue who is gonna look at the grammar, if the core devs understand the issue that's enough 
True lol
That's good 👍
Now then
Now the entire fork thing
Oh hey, is that you? 😄
Oh hey
When I made my commit I just edited from GitHub but apparently you can't do that so not really sure what you do next lol
I am guessing you want to be assigned to the issue?
You can edit from GitHub, it will create a fork automatically
https://github.com/NIRDERIi/bot Is that the correct fork way?
yep
Oh great, so now I should edit what needed?
bot/constants.py line 437
discord_py: int```
Yeah, that's the constant
Right there ^ you want to add Channels.discord_py to the tuple on line 53
I press it in it says 404
Go to your fork
Then bot/exts/utils/utils.py
ah, it is a capital i, not an l
It's on edit mode here
Yep, you want to add the channel to in_whitelist.channels
.. that's what you just did
Oh so it's ready?
okay 😄 can you remove the last comma and commit?
last comma and extra whitespace
I did the commit
So that it looks like this
bot/exts/utils/utils.py line 52
@in_whitelist(channels=(Channels.bot_commands, Channels.discord_py), roles=STAFF_ROLES)```
Yep
(Make sure to add "solves [#yourIssueNumber](linkToIssue)" to the PR message)
What to do here?
I entered this link
huh, interesting
it works for me
click compare across forks
This is what happened when I pressed the link Akarys sent

on the left select python-discord/main and on the right NIRDERLi/main
Yep, that's what you want
thats right, now you just click create
In the PR body, yes
In the box that shows when you press "Create pull request"
Just Closes #1684 works apparently
Oh just Closes #1684 ok
Closes #1684 is enough, github will automatically link the issue
And then describe the commit you made I guess (add support for !charinfo command in #discord-bots)
and a sentence or two describing the change and why
Seems like it is in the title
you don't have to be as descriptive as in the issue
the whole body could be Closes #1684 - added discord.py to the channel whitelist for charinfo
perfect
Oh ok
I am creating the pull request now
Closes #1684
Add support to charinfo command in discord.py channel
Was it already approved?
lol
is a 10/10 emote
Now we just wait for linting
Thank you @green oriole , @static canyon and @fervent sage for the help!
why are there no smile emojis that arent creepy or outright terrifying lol
lol you're right
woo charinfo in ~1 min
So you can use it there now?
It should be live in a couple of minutes
Oh ok
Like that one?
yup
Also @fervent sage, would you have, by any chance, a minute or two to spare? :3
sure!
Thank you for the help!
https://github.com/python-discord/bot/pull/1666 please review 🥺
anything to take my mind off the oppressive heat lol
done :P
?
not sure if timestamps have rolled out everywhere on iOS yet
they should be out on all platforms, if people update to the latest version
Heyo @gritty wind, do you have access to discord timestamps yet? <t:0:R>
@patent pivot I feel like you'd be the one to know, as you're an apple user.
oh lol
Scale didn't have the update last time
yeah they have rolled out
The new version is live, just not everywhere last time we checked
How did you do that?
<t:1:R>
Yep, you have to paste a Unix timestamp
Bump, vco's commit reminded me of this
Done transferring, feel free to add priority tags if you wish alec
hm that reminds me of something i was thinking of, so we all know the .github command is kinda useless now that we have inline resolving, so my proposal is that we make it focus on one PR or issue and provide extra detail, like who authored it, when it was created, and the thing that reminded me, its tags
i feel like none of the two issues are part of the quackstack repo as they are related to
which are part of branding
aren't accessories, just emotes
but the PRs will be made to Quackstack
smth like
do labels have a hierarchy like discord-roles?
iirc it depends on the order they're applied
we could put the embed colour as the priority level or maybe ^^?
like priority level have some colour but parse them and put accordingly?
we cant guarantee it will have a priority
if none, then just keep it blank
imo we should put the colour of the 'thing'
so an open issue is green, closed is red, etc. for prs
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
😄
the last letter changes what it looks like

Sweet
I do believe we have considered it at some point, but, with the current iteration of GitHub embeds, I’m not sure what we can do to top it
Wait, it converted it in my phone to my language cool
guys i am making a pokemon game
just letting u know before i can push
||and have to live up to my username 😂 ||
If it's related to a pydis bot you need to make an issue and have it approved by a core developer before adding features to the bot
related to sirlance bot
you need to make an issue at https://github.com/python-discord/sir-lancebot proposing the feature first
okay making one
i want to start contributing to sir lancebot
i just need to follow the instructions and choose an issue or?
or is there something else i must do beforehand?
That's mostly it, set the bot up, pick an issue, get assigned and work on it
ah that is quite nice
you can also write up your own issue if you have an idea, just make sure to get approval before a PR though
allright
well i dont really know what the bot does tbh, im just in for some python experience
taking a break from my main lang and exploring some other langs
100%
Just remember us when you're famous
Um…permission ?
Permission for what?
patience 
Okay..

Anyone play around with the new issue template features?
It seems contact info overrides any other templates
Can't figure out how to get everything to show up
I take that back, it seems to be the blank issues flag that does it
hmm that's not it either, I've removed the entire file lol
how do u make one? I cannot see any place in the UI to do so? just write the yaml and push it?
It'll prompt you in various places, such as the settings tab, but you can also just push it
That's nice and all, but it really doesn't solve the problem lol
I figure it's because I was testing on a repo that doesn't have it enabled
I'll push it to the actual forms repo and see how that goes
templates are opt-in waiting list beta, so if you aren't in it, that ain't going to work
Re: pixels#122
Nice idea but wouldn't this increase the moderation task on the API, basically say a use authenticates himself with Google, Discord, and GitHub, so he has 3 accounts. If you want to ban him, you would need to get his other two accounts too which can only be done through email checking on the three accounts, (which wouldn't really be liked by many, storing their emails). I can only see this way to completely ban a user from the pixel API from all their accounts.
If we were to go ahead with this issue, all of the authentication methods would point to the same user
According to the status:WIP I think this was discussed in the pixels dev channel so I didn't take it up on the Github issue and rather asked it here.
Umm how would you point to the same user?
We would require you to link your Discord account when activating the other auth methods, I'd say?
Oh i didn't think of that, that could be a nice way
Like, you must get a token from your browser first for OAuth, I'm pretty sure. We could have an /activate_token endpoint that will make your OAuth code start working but for that you need a Pixels token to perform the request.
No, I may have worded it weirdly. Each authentication method would have different ratelimits (but it would of course be the same user).
Say the rate limit is 2/120s, and I have two ways of authentication. Then I could possibly send 4 requests in 120s, but both authentication methods would point to me
This is all kind of pseudo-whatever. But think of it as this way..
We have 2 tables
- One central table, this stores some form of internal ID as well as the connection to Discord
- Per authentication table that relates to the central user table, this is where we look up and verify users. To see if someone is banned we just check the central table
Also you may be confused with the scope of the issue, I don't mean adding several ways for someone to get a pixel token. As in having sign up with GitHub, sign up with Discord, sign up with Google.
I mean that there should be several ways for someone to interact with the pixels API. So we may have JWTs (like now), username + password type of thing, OAuth2, and other interesting technologies.
I hope that cleared it up for you
@tawdry vapor how realistic is it to enable /dev/shm in snekbox
multiprocessing and a few other async tools rely on shared mem
If we can find a way to set limits on it then we could enable it
It was disabled due to an exploit that allowed using unlimited memory
There might be a cgroup for it, IDK
the mount would look like ```
mount {
dst: "/dev/shm"
fstype: "tmpfs"
rw: true
}
But it is separate from the normal memory one
so we just need to figure if nsjail can limit the sizes of the tmpfs' it allocates
I think that is all you have to do, yes.
I'll have a look into it, thanks for confirming
--tmpfsmount|-T VALUE
List of mountpoints to be mounted as tmpfs (R/W) inside the container. Can be specified multiple times. Supports 'dest' syntax. Alternatively, use '-m none:dest:tmpfs:size=8388608'
size arg indicates it supports a limit
it might be as simple as throwing size in that map? huh
config.proto lines 41 to 42
/* E.g. size=5000000 for 'tmpfs' */
optional string options = 7 [default = ""];```
yep, just stumbled across that myself
will give it a test locally to verify it behaves as expected, since we're only doing 2 parallel execs we can safely allocate 50mb per execution for shared mem
So that's like 200mb total for memory?
50+50 for each gunicorn worker
Plus whatever the Falcon app uses
yep, 200mb total possible for executions and then just overhead
Would appreciate some eyes on this small fix https://github.com/python-discord/bot/pull/1690
!server
Created: <t:1483877013:R>
Voice region: europe
Features: WELCOME_SCREEN_ENABLED, BANNER, ANIMATED_ICON, RELAY_ENABLED, VIP_REGIONS, DISCOVERABLE, INVITE_SPLASH, THREE_DAY_THREAD_ARCHIVE, NEWS, COMMUNITY, PREVIEW_ENABLED, PARTNERED, VANITY_URL, PRIVATE_THREADS, MEMBER_VERIFICATION_GATE_ENABLED, SEVEN_DAY_THREAD_ARCHIVE
Roles: 86
Member status:
48796
181374
Helpers: 121
Moderation Team: 33
Admins: 15
Owners: 3
Contributors: 39
Category: 32
News: 8
Staff: 69
Stage_Voice: 1
Text: 174
Voice: 8
Look, I am a good dev now
Why is Europe not capitalized ? 
That's what ctx.guild.region returns
I wonder why Discord does that
We could capitilise I guess
Let's capitilise it
I don't think I have any right to joke on spelling now 
with there being some with underscores, not sure just capitilising will make it better
I guess you don't always capitalize enum options
Also, I guess we're not important enough for vip_amsterdam 
Why aren't we on VIP regions actually?
They've been phased out
partners and verified servers are upgraded to a high bitrate on all regions
Interesting
why are there 69 staff channels
nice
Lmfao @green oriole
What again
Did you also struggle and do it via Web ui?
I don't want to grab my laptop again
I did the same
Oh yea
I trust yours more than mine
I would lol
Oh actually, I can't approve
I had to make 2 branches because of autocorrect lol
Haha
I had to load desktop version on my phone to approve it
Yay, that's probably the most risk I ever took to make a PR
Lol
Glad it is merged
hmm, I can't find a great way to figure out if /dev/shm limiting is working
well
when I try this poc I get exit code 135
nsjail conf:
mount {
dst: "/dev/shm"
fstype: "tmpfs"
rw: true,
options: "size=12"
}
python:
from multiprocessing.shared_memory import SharedMemory
try:
mem = SharedMemory('test', create=True, size=128_000)
mem.buf[:128_000] = bytearray([1] * 128_000)
except FileExistsError:
pass
but it seems to have to be significantly higher to trigger it
hmm, if I try ```
mount {
dst: "/dev/shm"
fstype: "tmpfs"
rw: true
is_bind: false
options: "size=10M"
}
and ```py
with open("/dev/shm/test", "w") as f:
f.write("H" * 15_000_000)
I get Traceback (most recent call last):\n File "<string>", line 2, in <module>\nOSError: [Errno 27] File too large\n
which seems promising
and now with multiprocessing shm I can reproduce that ```py
from multiprocessing import shared_memory
shm_a = shared_memory.SharedMemory(create=True, size=15_000_000)
shm_a.buf[:15_000_000] = bytearray([1] * 15_000_000)
my guess is that the tiny byte limits aren't enforced by the kernel
I'm going with 40mb of shm
hmmm
hmmm
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "/usr/local/lib/python3.9/multiprocessing/context.py", line 119, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild,
File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 242, in __init__
self._task_handler.start()
File "/usr/local/lib/python3.9/threading.py", line 892, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread
I wonder what limit this is
okay so
it's the PIDs limit
because even with pool size two multiprocessing seems to be trying to spawn over 5 threads?
okay, because it allows mp.Pool to work, I'm going to set the PIDs limit to 6
Is it related to
processes is the number of worker processes to use. If processes is None then the number returned by os.cpu_count() is used.
How reliable is setting it to 6? Ideally we should understand why 6 works
!e print(import('os').cpu_count())
@sharp timber :white_check_mark: Your eval job has completed with return code 0.
2
There are three handler threads within Pool(), 2 PID's for the pool threads, and presumably one more for the main thread
!e ```py
import multiprocessingimport multiprocessing
import threading
if name == "main":
multiprocessing.set_start_method('fork')
pool = multiprocessing.Pool()
print(threading.get_ident())
print(pool._worker_handler.ident)
print(pool._task_handler.ident)
print(pool._result_handler.ident)
print(pool._pool)
Won't run cause shm isn't enabled rn I think?
My machine gives:
4445253128
123145553616898
123145570406402
123145587195906
[<ForkProcess name='ForkPoolWorker-1' pid=1129 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-2' pid=1130 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-3' pid=1131 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-4' pid=1132 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-5' pid=1133 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-6' pid=1134 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-7' pid=1135 parent=1113 started daemon>, <ForkProcess name='ForkPoolWorker-8' pid=1136 parent=1113 started daemon>]
4+workers
What determines cpu_count in our prod env?
I think what we would need to do is check the configured PID limit and override it if it's insufficient for creating a pool
By comparing the config against 4 + cpu_count
That being said, I also don't want to force users to allow a high PID count. Maybe there needs to be an optional argument to enable what I described above.
!int e print(import("os").cpu_count())
In [1]: print(__import__("os").cpu_count())
4```
that's interesting
diff CPU count in snekbox
@clever wraith :white_check_mark: Your eval job has completed with return code 0.
2
Wat
https://github.com/python-discord/site/pull/508
If anyone is free, do have a look at this PR for a review
Hmm the new native relative timestamps lack granularity. I want to know how many parts of a year passed, and not just full years
!server
Created: <t:1483877013:R>
Voice region: europe
Features: THREE_DAY_THREAD_ARCHIVE, PRIVATE_THREADS, MEMBER_VERIFICATION_GATE_ENABLED, ANIMATED_ICON, PREVIEW_ENABLED, VANITY_URL, PARTNERED, WELCOME_SCREEN_ENABLED, INVITE_SPLASH, RELAY_ENABLED, DISCOVERABLE, COMMUNITY, BANNER, VIP_REGIONS, NEWS, SEVEN_DAY_THREAD_ARCHIVE
Roles: 86
Member status:
50455
180164
Helpers: 121
Moderation Team: 33
Admins: 15
Owners: 3
Contributors: 39
Category: 32
News: 8
Staff: 70
Stage_Voice: 1
Text: 174
Voice: 8
Can't you fine-tune that?
As far as I'm aware there's only one format for relative time
You can hover it to see the full timestamp
i'm going to be doing some devops in #763406158522220544, https://status.pythondiscord.com/incident/98105 this maintenance
Wdym like 5 years, 2 months 28 days and 5 hours
https://forms.gle/zSwDrjdajRz7DkuM6 please submit easter eggs
understandable
I mean it's joe what do you expect
Same
is this the text channel for the dev-voice channel?
yeah
thanks!
the inside of joe banks is abusive 
dev voice happens so little that there isn't anything else
Yeah and it's not open to all people all the time
@clever wraith so forgetting is just you segfaulting
Just Contributes I think
so this is a rare privilege!
Joe do you plan on deleting the link?
@vale ibex I shall review your PR this instant, if you are awake.
Dereferenced NULL pointer
the sir lance one
I wouldn't exactly call listening to a joe rant a privilege
post-stream
my easter egg submission is unbeatable
No mine is

damn, this is hella intresting and I have no idea what's going on
Vco said mine is the best therefor it is
no really it is
I'm not even in the vc
what is it lmao
I'll dm it
ttt
hell?
yes
what's the issue btw?
There's many
gotcha, we're not working on a github repo?
ok it is a beautiful easter egg
@hollow cedar I knew I recognized your voice lol
I didn't see your name though so I thought I was going crazy
I've never heard their voice
this is great, there's so much going on
There are multiple people talking at the same time, this will not work
transcribe it in multiple lines
hahaha
@fervent sage take: https://github.com/python-discord/sir-lancebot/pull/790
@wild ridge greetings.
haha hey
why are they called pull requests? aren't they really push requests?
anyone can pull
but you need to request to actually make changes
pulling into main
youre requesting to pull your code into the main branch
but isn't that pushing your code
nah
if you're main
and there's a different branch
you're pulling the other branch toward you
it doesn't happen until you're pulled in
but I'm not main
you push to your branch and request you have the content of yours pulled into another
but isn't the content pushed into the other
because you're doing it
everyone loses lol
for someone else to pull it
this is so confoozling
hello @mellow hare
hi
@patent pivot would you use this as your Mac terminal theme?
is there a description here of the tech stack that powers the discord server?
@vale ibex sir-lancebot#790 merged. Thank you @fervent sage for the review.
@patent pivot
joe is our tech stack
can i put it in changelog 
lmfao
Hi Xith
do you even have perms
yes
oh
:D
I mean that's objectively false
Which stuff?
infraction type stuff
I can try to be yeah
hem youre too hot and want the sun to go away
Just just toss me the pr
that's why he complimented you - so you'd feel bad asking him for something
it's all part of his master plan
That is actually correct
That'd be some serious foresight on my part
@mellow hare (and anyone else, if you're up to it) bot#1682, bot#1680.
oh i thought i approved the second one a while back lol
I am bad at contributioning so that'll be a pass
28 people in vc O_O
i tested and apparently forgot to approve
/O_O\
This is typically why I cap it at 25 in the other VCs
This is a special case going on
we shouldnt have changed the perms lol
lol, no seriously 🤣
such a pity he runs on macos
but at least it isn't windows
everything in the picture in #announcements is part of the tech stack
where is redis
I'm on a macos right now, linux distros are hard to configure for a daily driver cleanly
The thing is, it's so easy to just gender someone correctly and it shows so much in terms of respect.
nope
worked fine for me
depends on the linux distro, perhaps
or the pc
you're going to make me arch btw
Dude and yall
yes, if im understanding right
you can add multiple remotes and pull/checkout from any
Right. And once again, most people aren't going to get offended if it's an accident, but the problem are those people who purposely missgender others
yeah, I've been trying to build out arch as my daily driver. it's a real pain. turns out, there's a lot about an OS that I took for granted
depends
I have real issues remembering that some people here are male instead of female, or vice versa
now arch is a pain
git remote add <name> <repo>
git checkout my-remote-branch
so just use they/them/their if you can't remember
It took me a long time to get it right, but I learned a metric ton of stuff along the way.
Like that video of someone refusing to call an african-american woman by Doctor
would love to swap notes
can't remember to do that either
that's something you should actively try to do
it's hard, I tend to default to he/him/his too
Yep. It happens a lot in real life too, and it really really sucks
but it's respectful
I don't have actual physical notes, but if you're having trouble ping me in an ot channel and I'll do my best to help.
I know, I just forget
language is a weapon folks, learn how you're being manipulated, and navigate from there
let's try keep dev contrib on topic for dev stuff, we are in dev voice right now 😃
its too late lol
i dont have the mental capacity rn to explain git stuff sorry
might be a good idea to build another channel just for the meta for this one
I see #867857957299290152
we have #751591688538947646 and #799641437645701151
Just made a #867857957299290152 channel for folks - yep
cheers hem
But it's likely better to scoot down to the other channels
all the chatter belongs in the non dev vcs and vc chats tbh
Yes yes I know
update: nginx deployed, https://policy-bot.pythondiscord.com/ is now serving through nginx
how do you ping a voice channel again
#!
@patent pivot maybe you want to disable devops alerts? =P
an organized clusterfuck
Band name
holy shit
@mellow hare Please review those PRs if you're able to. On a completely different note: morning.
Yes yes yes
uh
Awake but not home
understandable, have fun at <place>
It was a very nice place
It had sheep, cows and llamas
I had a burger for dinner and was wondering if it was one of the cows family
Gotta love British countryside pubs
Anyone know who NotFlameDev on GitHub is on here?
:P
Would bot#1642 just be a matter of updating https://github.com/python-discord/bot/blob/main/bot/exts/info/doc/_cog.py#L341-L347? If so might have a go it
bot/exts/info/doc/_cog.py lines 341 to 347
if doc_embed is None:
error_message = await send_denial(ctx, "No documentation found for the requested symbol.")
await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)
with suppress(discord.NotFound):
await ctx.message.delete()
with suppress(discord.NotFound):
await error_message.delete()```
- bot#1624
yeah it should just be that
it's just one instance on one node
no, one total
yeah
any pod which has the annotations ```yaml
prometheus.io/scrape: true
will get scraped
uhhh
yea
https://paste.pythondiscord.com/akuqofebup.yaml?noredirect @clever wraith looks something like this
## towards top of file
DELETE_ERROR_MESSAGE_REACTION = '\u274c' # :x:
...
# inside command
error_message = await send_denial(ctx, "No documentation found for the requested symbol.")
if ctx.message.mentions or ctx.message.role_mentions:
await error_message.add_reaction(DELETE_ERROR_MESSAGE_REACTION)
try:
await self.bot.wait_for(
'reaction_add',
check=lambda reaction, user: reaction.message == error_message and user == ctx.author and str(reaction) == DELETE_ERROR_MESSAGE_REACTION,
timeout=NOT_FOUND_DELETE_DELAY
)
with suppress(discord.HTTPException):
await error_message.delete()
except asyncio.TimeoutError:
await error_message.clear_reaction(DELETE_ERROR_MESSAGE_REACTION)
else:
await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)
with suppress(discord.NotFound):
await ctx.message.delete()
with suppress(discord.NotFound):
await error_message.delete()
```maybe something like this?
Not sure if the two suppressions are necessary in the else but the current code does 2 so just copied
Does this look right for merging a PR from my fork to Pydis?
yep!
What does that mean?
that linting failed, specifically:
Black isn't compatible with our style guidelines. We do have a pre-commit hook people can use if they want.
Hey have a look at our contributing guide to learn how to setup all our tools (linting with flake, and pre-commit)
Let's see if this works
God damn it
Don't understand that
Is there any error in the code?
Forgot to import partial
Missing a , now lol
You can do poetry run task precommit to install the pre-commit hooks
Assuming you have done poetry install already
I really should be can't be bothered to set everything up on my laptop lol
Did on my PC and it was a real hassle for me
Can't figure out what's wrong now 
Not got any errors in my IDE
You have trailing white space on a few lines
Like:
‘print(“hi, notice the space after me”) ‘
I really wouldn’t recommend using the CI as your personal linter, it’ll probably be more hassle than it’s worth
Which IDE are you using?
PyCharm
You sure?
That’s what the CI is saying currently
I’m on mobile so it’s a bit hard to pull the actual line
Think I found one line at the end
If you run the hook locally, it’ll actually fix it for you
I can't run it locally cause I haven't set it up
Can't find any trailing whitespace either
Gonna try setting everything up on my laptop
There's no rush on making these changes, if you wanted to wait until you were back at your PC
Also, if you run into any issues feel free to ask here
I really can't figure this out
I've downloaded everything into PyCharm, and have installed dependencies via poetry
Then copy-pasted the code I committed into PyCharm and the only issues are ones that isn't really to what I did (e.g. Unresolved attribute reference 'trace' for class 'Logger' and Unresolved attribute reference 'endswith' for class 'ValidURL')
But if those are errors then why is the bot working right now?
They're not errors, just the static checker not understanding non type hint annotations and dynamic code
A trailing whitespace somewhere
let me take a look
L471 and 472 have whitespace that shouldn't be there, maybe some others too
When you run the pre-commit hook, it fixes those for you, but doesn't stage the changes
How do i do this?
so you it might look like there aren't any trailing spaces in your code because they've already been fixed by the hook
poetry run task precommit to install the hook
It'll run automatically on commit, or you can run manually by doing poetry run task lint
Thanks, fixed those two
God damn it more lint errors xD
Something that's really nice with GitHub, is that if a lint action fails, the lines will be highlighted in the files changed tab
At least it says these ones
You can also configure pycharm to strip trailing whitespace on each save
it's not something you should have to look for manually
I202: Additional newline in a group of imports. 'from discord.ext.commands import BadArgument, Cog, Context, group, has_any_role' is identified as Third Party and 'from discord import Colour, Embed, Message, NotFound, Reaction, User' is identified as Third Party.
How do I fix this?
It doesn't like the blank line on line 16
doesn't or does?
Wait sorry misread
I'll remove that
[flake8] F402: import 'group' from line 16 shadowed by loop variable
I can't find this "loop variable"?
Ah got it
Finally succeeded. Now need to make some changes
@brazen charm If I undo the "style changes" I'll have```py
def predicate_emoji_reaction(ctx: commands.Context, error_message: discord.Message, reaction: discord.Reaction, user: discord.User) -> bool:
I can do```py
def predicate_emoji_reaction(ctx: commands.Context, error_message: Message, reaction: Reaction, user: User) -> bool:
you can split up the definition
Using what style?
the one other definitions in the cog use
So I should keep the full thing with the imports?
def predicate_emoji_reaction(
ctx: commands.Context,
error_message: discord.Message,
reaction: discord.Reaction,
user: discord.User
) -> bool:```
Yes, that'd be preferred. But like I mentioned the function would be more fitting as an util imo as it can already be used in multiple places
Yeah I'll make it a util
What would be a good function name?
with suppress(discord.NotFound):
await ctx.message.delete()
with suppress(discord.NotFound):
await error_message.delete()```and do we need two suppresses here?
if you had:
with suppress(discord.NotFound):
await ctx.message.delete()
await error_message.delete()
the second delete will not execute if the first one fails
Ah, I see
CC @brazen charm
delete_if_no_mention or something like that, I'm not particularly good at naming
the pypi command and possibly others in the future also delete invalid invocations, we should extract this to an util function under utils.messages instead of only implementing the functionality for this cog.
So it'd be something like```py
async def delete_if_no_mentions(ctx, error_message):
if ctx.message_has_mentions:
# don't delete invocation message
# allow deletion of error_message through reaction
else:
# wait then delete ctx.message and error_message```?
And should I make this a separate issue? (since is no longer strictly relevant to the "prevent ghost pings")
CC @brazen charm
I think doing a deletion under a mentions condition would be enough, as the caller can do its own wait_for_deletion on the bot response message. maybe don't need an util at all then, with just your if around the ctx.message deletion, although it would be a bit nicer
Unless I missed something and handling the reaction deletion on its own is required, didn't look into it in depth
It's not, but from my understanding we'd do it every time this function is called
So might as well have it as part of the function
Also ^ @brazen charm
Not really, could be good for flexibility. If the message contains no mentions let it return immediately, otherwise wait for the reaction
That wouldn't necessarily work
Because what you delete after reaction is different to if there's no mentions
if message.mentions or message.role_mentions: # has mentions
if reacts:
delete_error_message()
else: # no mentions
wait()
delete_invocation_message()
delete_error_message()
Maybe ```py
if has mentions:
if reacts:
return True
return False
wait()
delete_invocation_message()
return True
```then if it returns True, delete error_message
That could work
Or even```py
delete_invocation_message, delete_error_message = call_util_func()
if delete_invocation_message:
await ctx.message.delete()
if delete_error_message:
await error_message.delete()```
Wait now I am confused, what is the difference between the code you made and wait_for_deletion()?
async def wait_for_deletion(*args, **kwargs) -> None:
"""..."""
if message.guild is None:
raise ValueError("Message must be sent on a guild")
if attach_emojis:
for emoji in deletion_emojis:
try:
await message.add_reaction(emoji)
except discord.NotFound:
log.trace(f"Aborting wait_for_deletion: message {message.id} deleted prematurely.")
return
check = partial(
reaction_check,
message_id=message.id,
allowed_emoji=deletion_emojis,
allowed_users=user_ids,
allow_mods=allow_mods,
)
with contextlib.suppress(asyncio.TimeoutError):
await bot.instance.wait_for('reaction_add', check=check, timeout=timeout)
await message.delete()
*truncated
Hmm
as I understand it something like this should be enough. The error message should be deleted unconditionally as it won't ever contain mentions, and has no information beyond stating that the lookup failed
await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)
if has_mentions(ctx.message):
with suppress(NotFound):
await ctx.message.delete()
with suppress(NotFound):
await error_message.delete()
This is what Akary's put. They suggested only deleting the error message if you react so went with that
The key thing is ctx.message doesn't get deleted when there's mentions
Ah! Okay I understand now
if doc_embed is None:
error_message = await send_denial(ctx, "No documentation found for the requested symbol.")
await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)
if not ctx.message.mentions or not ctx.message.role_mentions:
with suppress(discord.NotFound):
await ctx.message.delete()
with suppress(discord.NotFound):
await error_message.delete()
else:
msg = await ctx.send(embed=doc_embed)
await wait_for_deletion(msg, (ctx.author.id,))
Can't we just do that then?
Add an if-statement for deleting ctx's message only
I think Numerlor wanted some of this as a util
it'd be nice if the conditional deletion was an util, but it's fairly short so not required. When I was thinking of an util I didn't realize we can just wrap it in a conditional
Well yeah that was the wait_for_deletion() code you made haha
Now it's so short and already a util.
Would we want Emojis.trashcan or Emojis.cross_mark?
I want to say the latter, but the former may be more fitting. Gonna double-check with how Emojis.cross_mark has been used previously.
I'm thinking Emojis.cross_mark too
where would it be used?
The reaction you use to delete error_message
it should be a trashcan then
But we don't use trashcan for error messages
We use ❌
(I think)
It's already a trashcan through wait_for_deletion
Your code doesn't need to touch that
!pypi d
It never gets used in reactions, only in messages.
Sourcegraph is a web-based code search and navigation tool for dev teams. Search, navigate, and review code. Find answers.
error_message = ...
await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY)
if not (ctx.message.mentions or ctx.message.role_mentions):
with suppress(discord.NotFound):
await ctx.message.delete()```so this should be what we want right?
You are accidentally closing wait_for_deletion() before all arguments have been passed
yep
Ah, now that looks correct yeah.
Push that and I'll review it
