#dev-contrib
1 messages · Page 38 of 1
He just join them after, so I don't think so
That's a seasonalbot generated message too
You can temporary add a print here https://github.com/python-discord/seasonalbot/tree/master/bot/seasons/evergreen/error_handler.py#L58 but you should try gdude method first
yes ?
Switching to the message converter and deleting the footer
Told you, because it reduce the number of API call, make it faster and allow more things
that code is alredy in ^^
Just change jump_url: str to message: discord.Model and get the jump_url from message.jump_url
And you can get rid of the history loop
we actually can't do it
You actually can?
it will then return .bm message
Akarys is talking about adding it in the sig and referencing the msg from the argument as it'll already have been converted. Not to use the ctx.message object
Why would you be getting muted 
guilty concious?
lol
the suggestion is the change the bookmark commands function to this
@commands.command(name="bookmark", aliases=("bm", "pin"))
async def bookmark(self, ctx: commands.Context, message: discord.Message = None, *args) -> None:
discord.Message being typehinted allows all jump urls to work and also ensures it checks internal cache first
less api usage
@commands.command(name="bookmark", aliases=("bm", "pin"))
async def bookmark(self, ctx: commands.Context, message: discord.Message = None, *, hint: str) -> None:```actually :)
TBH i prefer the current version , no offense
you can prefer it, but we don't
getting message from cache can lead up taking message from other channel
That's the point actually
I think you misunderstrood what I meant earlier, AG
the argument provided is a jump url. it's unique to a single message
IDs are (almost) unique too
they are always unique
All messages have unique IDs, even if it's just the ID. However, the converter can even convert an ID to a Message object of a message sent to another channel if the message is still in cache.
So, it's a plus, not con
an automatically created general channel has the same ID as the guild on purpose
Actually two messages in different channels can technically have the same ID well, I thought I read that somewhere, my bad
but we are not taking message ID by any ways
no they cannot akarys
they can
The snowflakes are specifically designed to be unique
The last part of it depends on the worker ID + the internal worker counter
each process generating IDs have designated identifiers that don't allow overlaps
it's why they're called snowflakes
they're ensured uniqueness
Yep you're right, it is written in the doc
I thought someone said me they can overlap
My bad
if you'd like to look at an eq implementation, give me a moment
None of us ever worked in discord anyways
I'm unsure your point AG
Are you talking about the worker ID?
they didn't
how do you know
Just by looking at the doc
because we work with it enough and get enough info through docs, updates, blogs
they used the snowflake ID model created from twitter because it can be sorted and retrieved semi-reliably by datetime (as the IDs are generated based on the current unix timestamp + relevant IDs appended to the end)
it's a good ID model specifically for nosql data storage, which they use. They rely on a db called Cassandra, which is designed to be most performant for quick and easy writes
in return it has lower performance with reading data
TBH we are making it hard for the user in the end
no we're not
its ok how it is now
the user experience has not changed
ok give me the syntax i will change it , test it , lint , push it
Are you asking for the code?
after the sig is changed, there's a small amount of adjustments still required in the function code too to use the message object rather than parsing the jump_url
i think i will take some resst
my mind can't process anymore
TBH
just let it be , it is
I am super tired
If you want to rest, that's fine. But you seem to be making this whole process a lot harder than it needs to be
cough cough
You've been questioning a lot of the review comments for no reason, you've marked unresolved comments as resolved, you've got a strange attitude anytime someone suggest a change
Which had at one point been marked resolved early. Unless a change has been made exactly as suggested, you should not resolve the conversation
But that's just one aspect of what I mentioned above
Yes, you just keep saying you want to keep it as is.
Reviews have asked for changes. This isn't for no reason.
cuz i don't really how to do that
i am not a experienced person
I never said i was
Then you'd ask how to do things, not just demand to keep it as is
We're a learning community, we are more than happy to step through how to implement suggestions when necessary
We don't expect everyone to know everything
But we do expect a willingness to be open and to learn
Like I said earlier, there's no rush and there's no need to prioritise this over anything else in your life. Just take things as they come.
At any rate, take some time to rest and come back when you've got some spare time. We can help go through any aspects necessary with you, there's no need to be overly frustrated trying to do it alone.
?
Should i add a feature that DM the person whose message is being bookmarked , just to keep him informed ?
@green oriole
Don't think you need, that's pretty useless
Also, can you add some logging when a user create a new bookmark?
Got some great contrib coming up....
On which issue?
Security...
On.. Python discord’s projects?
Nah, just a developer tool that I have built, free doe.
This channel is for contributions for pydis’ projects :)
Hey g!
@green oriole there ?
what do you mean by logging ?
Doing logging : log.info(..)
I think just adding log.info(f"User {ctx.author.id} bookmarked message {message.id}" or something like this (you should test it first) should be enough
Ok
Not sure of the syntax of the sentence, but yeah
Do you want to delete the ctx message cuz that contain personal detail like Hints how people name other people , how they remember and all
ctx message
.bm message
not from log
like I do .bm afasf
and that message get deleted
@crude gyro Is this still necessary? https://github.com/python-discord/bot/pull/76 If yes, should it be done for our API client too (it uses its own session)
i don't believe it's necessary anymore, at least last time i looked at it. but there wasn't a major reason to revert it either unless we worked on the session code again later down the line, so it's just been left alone.
nice
I kinda got stuck though
aiohttp doesn't want sessions created outside a running event loop, which is what both the bot and api client do. I can take care of that for the bot, but not for the api client. This is because the api client is needed for the api logging handler, which currently queues up log records until it detects that the event loop has finally started running.
Currently aiohttp doesn't enforce it (surprisingly I don't even see the warning being logged, not sure why). But it will in in 4.0, if discord.py ever upgrades to that
whres the api client atm
It's instantiated inside the bot
Well, before I subclasses it was created in __main__ and added as an attribute to the bot
I think if the creation of the API log handler is delayed, then the API client and its internal session can be created when the bot runs.
But this means log records before the bot starts will be missed
The handler does have to wait for the bot to start regardless, since it relies on discord.py to start the event loop.
they're just queing tasks, which is fine
ok, so
in APIClient
start with self.session = None
have a coro defined that creates the session and assigns it
If we want to also preserve those initial log messages I think we'd have to make it so the handler doesn't get the client right away (since it queues tasks, it doesn't need it until the loop is actually running anyway)
create a new attribute for APIClient that's an asyncio.Event
in init, do loop.create_task(self.setup_session())
the setup_session creates the session as well as sets the asyncio.Event
But it won't have a running event loop yet
doesn't need it
lets say the asyncio.Event is put on self.ready
APILoggingHandler.ship_off can start with the line await self.client.ready()
and everything else goes on as normal
this way you can keep queuing logs for the api, they don't actually try send until the api session has been created, and that will only happen when the loop starts up as its done within a task also
Ok that sounds promising
I'd need to raise an exception if the client tries to be used before it's ready though but that seems doable
the logging stuff
Ok sure but it's just a fail safe
we cant guarantee the next programmer will wait for the ready event
ok
then put the waits in the methods
that'll make it global and ensure all api session usages must wait until the http session is created
async def get(self, endpoint: str, *args, raise_for_status: bool = True, **kwargs) -> dict:
"""Site API GET."""
await self.ready()
async with self.session.get(self._url_for(endpoint), *args, **kwargs) as resp:
await self.maybe_raise_for_status(resp, raise_for_status)
return await resp.json()
Yeah I suppose that's better than an exception 🤔
won't even need to touch APILoggingHandler then too
since it's using it with .post
which will also have a wait
it's just to ensure the loop gets time to do the client creation first since there's no other wait to wait for that to happen
and the task to do just that will always be scheduled before practically any others
it's just asyncio has no guarentee for doing it in order so we gotta do this as a failsafe
Thanks, I will try it out

just don't forget to have the setup_session coro do self.ready.set() after creating and setting the session
otherwise nothing will go 😄
Yeah, and I realised it must set it instead of designing it so that it waits for the event
cause then the whole order of tasks thing comes into play
I may be overengineering this 
Can someone approve either the time unittest PR or the remaining time PR
So I can finally add test to the other PR lol
I've already done that right
they don't call me the review king for nothing 
They might get reviewed tomorrow since it's the weekend
Plus there are usually some reviews after the meeting
if only the earth were flat
what the hell is going on with these tests
they are nested extremely deep
maybe just a PyCharm bug
it reached the maximum recursion depth
I have a test failing for constants and I don't know why cause I didn't touch them
:\
oh it may be using my config
Lol, did you try running manually in terminal just to be sure?
Hmm, then yeah prob something with config
I just think my config has a mistake
I didnt expect the tests to use it
Yeah it's cause I am missing a wolfram API key
what the
it checks the type annotations of the constants
it's annotated as string
but missing results in a type of None
hence failure
hmmmmmmmmmmmmmmmmmmmmm
requesting my reviews
my review is:
Mark is a pretty nice guy and I'd buy him a beer if I met him in person.
4.5/5 stars
from bot.bot import Bot
lol
Hey man I told you the imports would be weird
ik, that's why i'm poking at it
I was thinking of importing it in init though

idk
in project init?
yeah
so it's just from bot import Bot
yea
yeah that's a possible thing but there's also not many things we import from bot atm
so
like i mean directly only from it
True
so yeah i doubt it's really going to be different
I personally don't mind either way
I had to fix the quotes in a docstring
I copied from website so they were the fancy quotes
fancy eh
can't be getting too fancy around here
wouldn't want to have people expect us to maintain such lofty expectations as smart quotes
tbh this looks pretty much exactly what i figured you'd do
the only thing i think needing to be done is to load it, make sure the bot launches and doesn't die a horrible horrible death
because pretty much any of this would cause instant errors if it was done wrong
Seems fine
I don't know how it'd go if it was to re-connect (dont think it would affect anything) or if it was to be stopped then restarted (which in practice we'd never do)
it should be fine
but there's an easy way to test
kill site while using bot
and then bring it back on
unless you meant discord reconnects, in which case they do nothing
Yeah I meant a discord reconnect
And by a restart I dont mean killing the process
I mean just stopping the bot but the process keeps running
like I said we'd never actually do that
But I made the effort to make it reset the sessions should that ever happen
how would you stop the bot but keep the process going. if we called bot.logout() it literally calls exit
does it exit?
we'd have to override that
i didnt know
yeah it does task cleanup then exit
inb4 i'm wrong and everyone points out how wrong i am
then where'd i get that stupid idea from
logout calls close
maybe once upon a time it did that
close is this
async def close(self):
"""|coro|
Closes the connection to Discord.
"""
if self._closed:
return
await self.http.close()
self._closed = True
for voice in self.voice_clients:
try:
await voice.disconnect()
except Exception:
# if an error happens during disconnects, disregard it.
pass
if self.ws is not None and self.ws.open:
await self.ws.close()
self._ready.clear()```
basically killing stuff
thank you though
nvm me then, please continue
it's murder
it's definitely murder
but it's not suicide
so it seems it doesn't explicitly call exit
and maybe i was thinking of something totally different
murder sounds fun
So like I was saying, mainly not sure how it'd behave if it's closed then run is called again
oh you can call many clients at the same time
yes
yep
but you also can run multiple clients under the one token
but only if you want to have the lib scream at you for not being able to keep up with ratelimits
It shouldnt crash at all, hmm, discord does not forbid it either
Rate limit will be fun
however you cannot run the one Client instance in multiple threads
because it's bound to a loop
which is thread local
i'll try launching this then
just stash it
yes
stashing in amongst those, alongside heights, the deep sea and the feeling of being appreciated
all terribly frightning
Im terified by stashing
Just try it sometime it's not so bad 🙂
should have stretched
that sounds like a mess, yeh
that took like 3 hrs of messing around and like 15 minutes of actual coding
or else
pssh I still have things in my stash from a year ago
oh mark hasn't seen the proposal
Oh right
do you remember what the infr search output looks like mark
If you've seen it and if Scragly somehow lost them imma murder u
ye it is
with equal sign separators
kids have no shame these days 😔
Anyway, scrags has made a nice version of it
how are those icons so tiny
If it has text mixed in they will be small
well yeah
Do fields!
aaaand that's a no lol
partially it appears to also be because of the emoji not being the full bounded size allowed
i blame @crude gyro
@gusty sonnet do you wanna review my pr too 
yeah that's probably my fault.
I could knock that out if you wanted. I can re-use the svg for the superstar icon I made
it's all fontawesome stuff
Time required to open Mark's newest PR in new tab: 5s
Time required to notice number of file changes: 0.5s
Time required to close the tab: 0.5s
Review was done in 6s. Or was it?
They're most just from fontawesome aren't they
ye
yes, with maybe like one or two exceptions
@gusty sonnet lol most of those are just import changes in all the cogs
if we're going to refresh the emojis, can we give them better names?
Yah I saw, I'll do a pull and test later, Imma find something to chew on first
I think I still got the icon PSD though.
They probably should be svg anyway, and I find svg much easier to work with actually - if I'm gonna be the one doing it
I hate svg so much.
but yeah you're probably right.
i'd be able to alter and make new ones easily with an svg around
I write the xml for the svg, I don't really use any program for it unless I need to do something that would be too complicated otherwise
that's pretty impressive
Well I am just gluing things together I'm not actually drawing complex paths in it or anything
i make mine in inkscape, simplify where i can and then run it through minsvg
my svgs at least come out clean
the ones from inkscape and especially illustrator have bunch of extra metadata and sometimes a nonsensical structure
it strips all that
sounds ridiculous to me to worry about xml cleanliness.
lol
Yeah probably cause you never have to edit the xml manually
but that's the way I work
I have access to the font-awesome GH, since my FA was for PyDis anyway I can grab whatever you need
i love it when they're clean raw too, but also because it reduces the size a fair bit
Thanks gdude but I think all the svgs are available online, with inspect element if needed
The premium ones aren't so easy to grab
I don't think we use the pro ones anyway
actually I think it's time I sent someone the latest version probably
we do on the site in a couple of places. but in the icons, pretty sure they're just solid
oh right, search is down isn't it
ye
So yeah I can re-do them in XML and if you want to re-name them then hand me a list of names
I mean SVG not XML
bot.api | WARNING | Cannot send logging record to the site: ClientOSError(104, 'Connection reset by peer')

feel like i've seen this before your edits too
wonder what the cause is
that error is pretty mysterious. I've had it for other things, not this though
Latest FA is 5.11.2, latest DL I have is 5.9, so I can update you guys either way
not sure who I should actually be DMing them to though
Alright
You've subcribed to daily FontAwesome updates! Reply with CANCEL to stop.
haha
I'm sorry, I don't recognise that response.
not sure what that means
Hey man someone will buy pro just for that one icon
oh
Ok I didn't know what you meant either then
@glass pecan Does the site log anything when you get that error?
Nope, they made it free
nothing special, no mark
i changed the log to log.exception this time
but it's just showing what would be expected
maybe it's cause that session doesnt use the fancy connector
i thought you kept that in
I did
oooh right, only on http_session
but the api log handler has its own session
lets see
well, the apiclient has its own and the handler uses apiclient
im unable to do anything because my terminal has captured all input for some weird reason
dammit pycharm, wake up
ok
it happens no matter which is used
tried default and asyncresolver
both show connection reset by peer maybe 50% of the time
yeah I dunno
some specific way the stars align to cause that on your system
If it's 50% of the time then there's no way I could have missed that message
¯_(ツ)_/¯
well it's separate from this regardless
the logs are sending fine
and the api is working without issue
and like i said, this happened to me before the change
so yeah, everything looks dandy
So what is the verdict on the connector
keep it?
remove it?
use it everywhere?
if we remove it we get rid of a dependency
but async dns doesn't sound that bad
aiodns
you'll need to remove the connector then, to be clear
otherwise it will probably break cause the docs say it needs aiodns for that resolver
i removed any special things from both
just waiting the appropriate 52 years for pipenv to relock

i think it's stuck
it finally unstuck
wonder why it took so long. that's the longest it's ever been
usually when it gets stuck for that long it will just fail, so that's surprising
the removal made absolutely no perceivable difference
looks like you got what you wanted then; a chance to remove a dep
Well we do barely use http_session anywhere
majority of requests use different sessions
which would be the api client or discord.py's own session
that should actually be refactored
unless those sessions require a setup of default headers, it should be using http_session
other than the site api client
everything else would be using http_session, or should be
I don't recall anything creating a new session
Apart from discord.py of course
seems fine then
thought you meant extensions were randomly making new ClientSession instances
lol
My point was just that you probably didn't see any difference because most stuff doesnt use that session to begin with
fair
at any rate, i think it's likely pretty safe
you can ask lmn too if you want just in case
yeah, if we have two other sessions with much higher traffic that have been fine without that connector
yep
@crude gyro so should we get rid of of the AsyncResolver and AF_INET session stuff?
or the opposite, use it for all sessions?
@glass pecan randomly came out of nowhere and left a ton of thing to change LOL
Since almost everything needs error handling, we have a central error handler that takes care of it. If custom behavior is necessary, a cog-level error handler can be used as well.
@tawdry vapor I think we put the async resolver in at some point to fix a memory leak issue
Oh dear
something about how we kept opening new sessions but not closing them
That's not observed anymore though is it
iirc @molten bough was the one who did it
oh, yep, I remember
that was because of how asyncio handled its DNS resolver
it was basically spamming threads
Cause like I said yeah, if we have two other sessions with much higher traffic that have been fine without that connector
if you have pycharm pro you can run the bot with the thread profiler
try it without my fixes, see if it still spams threads everywhere
I've never used that feature honestly but I will have a look tomorrow
It's great, it can show asyncio coroutines as well
@green oriole removing the ability to select last message if none is given :C
Got it
This better pass now , i fulfilled Lemon, @green oriole , Scragly Request
Any thoughts on me making a PR that adds html documentation via sphinx?
add a issue first
@hardy gorge
will this do if none is given ?
or this
Anyways DONE
used this one
I'm having an issue setting up the bot for this second time, it's probably something I missed in the config file but no idea really
I don't know if this is the proper place to ask for help on that
sure
but anyway, the issue I'm having is that !help doesn't work in any channels other than #bot-commands, I have an issue everywhere else
Ah didn't see you online!
here's the traceback:
damn Vim it doesn't work like Emacs
hold on
help isn't working in certain channels in the live bot either atm
pretty sure it's a bug
needs to be fixed
well I do know where the problem lies
though it's pretty obvious
but I don't know anything of the code so
bot_1 | File "/bot/bot/cogs/help.py", line 453, in start
bot_1 | await session.prepare()
bot_1 | File "/bot/bot/cogs/help.py", line 207, in prepare
bot_1 | await self.build_pages()
bot_1 | File "/bot/bot/cogs/help.py", line 361, in build_pages
bot_1 | can_run = await command.can_run(self._ctx)
bot_1 | File "/usr/local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 935, in can_run
bot_1 | return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
bot_1 | File "/usr/local/lib/python3.7/site-packages/discord/utils.py", line 318, in async_all
bot_1 | for elem in gen:
bot_1 | File "/usr/local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 935, in <genexpr>
bot_1 | return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
bot_1 | File "/bot/bot/decorators.py", line 43, in predicate
bot_1 | if ctx.channel.id in channels or ctx.channel.id in hidden_channels:
bot_1 | TypeError: argument of type 'NoneType' is not iterable```
and that's in this line
if ctx.channel.id in channels or ctx.channel.id in hidden_channels:
wonder which it is. channels or hidden_channels
hidden_channels is None
and I'm not an expert on linting
wheres that defined
def in_channel(
*channels: int,
hidden_channels: Container[int] = None,
bypass_roles: Container[int] = None
) -> Callable:```
but why is it None by default instead of []
I see
because any modifications done to it carries across to multiple calls
since it's the same list object as was defined when the function itself was defined
so instead there should be a like that's like
hidden_channels = hidden_channels or []
within the function code itself
yes
if you do, let me know
this is considered an annoying bug and i'll review and merge any PR immediately
just realised you said issue so corrected my statement so you don't think i'm forcing you to code a fix
yes but I did want to tackle it myself
doesn't matter, I'll take something else
yes
just do that edit and create a PR
but the writing the issue will take me 6 hours and I'll make GitHub crash with my poor skills
lol
99% of the time, i'd say make an issue first
for this single line, don't bother
okay!
sounds good
I want my hand to be held
seems to be working now
that is awesome news
not sure if I should think of any other issues
okay
but you've identified a bug
which is great
and the scope of the PR should be on that bug
so, I'll show you the small tiny change too
we don't mind if you clean code up around the area you touched as a bonus, but if it doesn't need it, leave it 😄
def in_channel(
*channels: int,
hidden_channels: Container[int] = None,
bypass_roles: Container[int] = None
) -> Callable:
"""
Checks that the message is in a whitelisted channel or optionally has a bypass role.
Hidden channels are channels which will not be displayed in the InChannelCheckFailure error
message.
"""
hidden_channels = hidden_channels or []
def predicate(ctx: Context) -> bool:
# ...```
is there one for bypass_roles
feels weird to have it happen to hidden_channels and not bypass_roles
no, that's why I mentioned before
that maybe I should think of any other issues
that's what I meant
it doesn't happen now, but I guess it could?
fair. in this case, since both of them have the same structure, it's a potential issue if we don't pass it
so best to throw the same edit in for that arg
future thinking!
got it
this is a good opportunity to check my broken English doesn't screw up the commit message
should I enter title + description?
i don't think i've ever seen you speak broken english
then again i don't follow you at every moment either
I've seen myself doing so quite a few times
i reckon i speak bad english more and it's the only language i know
a concise title is required
is this PR or commit?
do we follow that thing where we write them in infinitive?
it's just commit
but I'll write the same for the PR I guess
definitive language?
yeah it's best
a commit description is a super big bonus, yeah
"Fix something" instead of "Fixed something"
it's not required though
yeah that's correct
also like
describe the code change
the description should have the reason
i've written an example, but i'll wait for you to show what you've got first
I also have a question about commit messages
I should know my editor but I never write descriptions lol
sure
lol wahats going on there
also red means it's too long
here's the example i wrote up
Ensure hidden_channels and bypass_roles use a list when not passed.
The in_channel decorator raised 'NoneType' is not iterable when it wasn't passed, due to the default value being None but not checked against before iterating over it. This edit ensures the arguments are set to an empty list in cases where they have a value of None instead.
double enter makes a clear separation of title and description, yeah
seems it doesn't count as the title if I do that
correct
I was thinking of being way more descriptive than that, like "Given this line [quotes the line] ... then after [shows when it fails]..."
I think I'll use your example if that's okay
I'll try to read commit messages later to get the style
no worries, have your breakfast man
Haha
Someone reminded me. Made me super hungry but now I guess I'll have to have a late dinner too
I have not checked since I use another account in GitLab without much protection
how do I identify to GitHub from here? I assume it wants a token too
You need to have setup your git account with your cli git yeah
Give me a couple of minutes and I'll be back at the pc
I would actually google it myself and read the docs but I forgot how it was called
2FA
I think I'll switch to SSH later
With 2FA enabled, you'll be asked to provide your 2FA authentication code, as well as your password, when you sign in or authenticate to GitHub.
After you've enabled 2FA, you must create a personal access token to use as a password when authenticating to GitHub on the command line using HTTPS URLs.
ssh is better though, yeah
$ git clone https://github.com/username/repo.git
Username: your_username
Password: your_token```
oh no
yeah make an access token
You can create a personal access token and use it in place of a password when performing Git operations over HTTPS with Git on the command line or the API.
excellent
I was complaining that I need to write the token itself
(or paste it)
that's a bit annoying
lol
lol
I lied, I added some small details to your description
its ok, i did a couple of small edits
oh noes I forgot to codeblock some things
clodeblock lol
no probs, anytime
hmm
I don't know how to use this still @molten bough
does that mean it's spamming threads?
My vm was running low on memory so I had to kill it
I can't even see any console for the output of the process
and the bot never came online
Well using the connector everywhere doesn't seem to make a difference but that isn't exactly conclusive given I have no idea how to interpret the results
or if I am using the tool correctly
What are you working on?
Determining if this connector is useful for the aiohttp sessions ```py
aiohttp.TCPConnector(
resolver=aiohttp.AsyncResolver(),
family=socket.AF_INET,
)
I was just reading back the conversation
I don't know anything about this, but that's a high thread count
Yeah but I suspect it may be it trying over and over again to do something
since the bot never even comes online
I have no idea what's going on cause I never get a console output
try running it normally
yeah it does run normally
yeah and do an eval that returns threading.active_count()
and do that a few times between playing around with commands
then compare counts with and without the special connector to see if there's much of a difference
5 threads vs three
that may just be cause I use the same connector instance for all sessions
I didn't manage to increase the thread count past 3 anyway
oh wait
it totally is going up without the connector
albeit gradually
Can you run an eval on production to see the current thread count?
!int e
import threading
print(threading.active_count())
In [1]: import threading
...: print(threading.active_count())
...:
32
Well that isn't too high but higher than a constant 3
My verdict is to keep it then
and use it for all sessions
If you run it with the profiler (the green grid circle looking button) you can get a thread graph in one of the tabs at the bottom
It should give you an idea of what's going on
When I ran with the profiler the process just exits immediately
Yes. It will start if ran normally after all
That's really odd
I guess it could be the VM, if you can't figure it out I'll see if I can do it when I get home after work today
You're welcome to try
Using evals I determined that the thread count is reduced with the connector though
So for now I decided that it should be used for all sessions
I don't know how constant it is, but trying to make the bot busy in roughly the same manner for both tests yielded a constant 3 for 1, and like 11-13 threads for the other
(it starts at 5 without it)
I'm really not sure why asyncio does this specifically
Er, aiohttp
The solution came from someone else that had the same problem
It's not like they don't know about it
Beats me
I'm curious what the thread count will be after the bot has been running for a while
an hour after being deployed, it was 32 in prod
It's based on how many sessions get created I think
One of the other possible solutions we had was a cog base class that came with a session
I don't think it's based on sessions; it's based on connections made aka the network traffic
Cause neither we nor discord.py recreate the session unless the the client is completely stopped or something
Hm, okay
I guess any time it needs to have dns resolution it creates a new thread
There is one thing I'm wondering though
It clearly doesn't happen with the aiohttp client discord.py uses, right?
I mean, if there are no cogs, does it happen?
Because you don't really hear people complaining about this
I think someone was just wondering about it
But if the bug was fixed then it would've been obsolete code anyway
discord.py doesn't do anything special with its session
it too uses the default connector
but has provisions for specifying a different connector
I didn't do any tests for that though, only have it on all sessions
And yes, brought up out of curiosity since this code was old. Also, if we removed it we could get rid of the aiodns dependency.
Not sure if right channel but please add !codeblocks not just !codeblock, I make the typo like 3 times a day now
Yes there's a PR open for that already but it's blocked by some other stuff
I need to test it first
Yeah that's part of the reason why it's blocked
I actually don't know what's going on with the discussion on that so I will check
To be fair the discussion probably does not need to be private for this
But it's customary to create issues on there for the meeting agenda and the discussion just remained there I think
There are couple of ways to deal with it, it was a discussion about dealing with it client-side or server-side
iirc it was decided to be server-side
I feel like at this point we should just merge it and change it later, cause the work is already done
And nothing conclusive has come from discussion
so it's just in limbo
seems like a waste of functional code to me
rip my - https://github.com/python-discord/bot/pull/542 lol
I guess it's time for that new thing
The thing we acquired from the meeting
No I meant merge your PR
ping relentlessly
Pulling
Resolves #468
Determine if the custom connector for the session is needed, and if it should be used for the API client and/or discord.py's sessions too.
Write tests? Testing the closing/...
A little PR 
So now PyCharm shouldn’t complain about api_client not being an attribute of Bot right?
I'm so tempted to suggest py if ctx.channel.id in (channels + (hidden_channels or [])):and watch my suggestion roasted lololol
Could be worse
Hmm, is there any reason you removed the log.info for the setup for wolfram cog @tawdry vapor
Nvm
More like it's the only one that has it
Oh then I just forgot
Yeah I just checked other cogs
None of them log anything
Prob a center log when loading
I did check for missed ones but apparently still missed one
Hmm
def setup(bot: Bot) -> None:
"""Load the BigBrother and TalentPool cogs."""
bot.add_cog(BigBrother(bot))
bot.add_cog(TalentPool(bot))```
If loading the first fail, it wont load the 2nd right?
Maybe
Hmm, if any of the cog failed to load looks like the bot will crash instead
I guess an exception check there is not needed
bot (bot.bot.Bot):```Yes
@clever wraith review done
@tawdry vapor would there be, in a blue moon, py await self.http_session.close()raise AttributeError coz of py self.http_session: Optional[aiohttp.ClientSession] = None
The arguments
@gusty sonnet I believe no because the super method will return early if the discord client is already closed. But not sure if it's considered closed when it's instantiated or only when explicitly closed.
Hmm
Other than that if someone manually reassign it to None it would break too of course but this is on the assumption no one will do that
Yep, this is purely assumption that it is even possible for that
Same with prematurely closing the session
It is
hmm
Done
The beefy part is the bot and the api
The rest are just import changes
No, I will stick to the current logic, since difflib wont be any different than what fuzzy can do
The problem is whether we want this on the bot side
Or do you think it's not worth it if the code might be tentative anyway
Well wouldn't difflib be simpler code?
Create / delete will add to the cache directly
It might be simpler, but the results are not as conclusive
I mean if like 1 function call can replace the whole custom one you've defined then that'd be worth investigating but I don't know if that's the case
Hmm, worth a try, I'll try again
It will be hard to read for oneline but yeah it can be shorter
Anyway I'll look tomorrow like I said it should just be merged instead of waiting for a decision this long
I don't mean one line
Just a question of
If anything I want to merge 679 or 680 first
Are you re inventing the wheel
Then merge the other right after with missing tests
Fundamentally it's different in algorithm and purpose
I used it with an assumption that people will type the tag in a short-handed way like f-str / fstr / fstring
@green oriole u mentioned to use k and r 2 times but i can only find only 1 that should be k and r . the one with args
embed.set_tumbnail doesn’t use it
@clever wraith
async def bookmark(self, ctx: commands.Context,
target_message: discord.Message, *,
title: str = None) -> None:```->
```py
async def bookmark(
self, ctx: commands.Context,
target_message: discord.Message,
*,
title: str = None
) -> None:```
You might also want to move that * down the line probably
@clever wraith stop
you've now pushed two commits that failed to lint
you have clearly not installed the precommit we asked you to
do that first, because any and all lint errors will prevent a commit from actually happening if you had that installed
pipenv run precommit
also make sure your commit title explains what you're changing, not why you're changing it.
this isn't descriptive enough
Okay, he/she is committing from the web interface
Can you please use the command line for it
So you can run precommit before
Hmm, inspecting got me https://www.mouser.com/images/suppliers/logos/adafruit.png
But it doesnt show on my chrome
Check the console
its just a indent issue
Ah yes, a reload did the trick, weird, I did reload 5 times
cuz i am on phone
please don't edit your PR on your phone
Well, do it later then
@green oriole you have to do it . i have no access to PC till 29 now
akarys is not personally responsible for your PR
if you're unable to complete it, comment saying so on the PR and an existing person can choose to finish it
can i put it on hold ?
Just leave a comment
it's near finished and not something that's absolutely requiring a specific person to finish, so no i don't think it's necessary to hold
i will call a laptop temp for few hour . from dad office to complete it
Please setup precommit on it
no it's fine. it's just one indent
there's no need to resetup a whole new dev environment on another system
we'll tidy that last point and it'll be done then
i can take a look at polishing it if needed
at least ill learn how to add commits to someone elses pr
You have the remote branch written at the bottom of the PR, you just push to it
@clever wraith would you be ok with me adding the necessary changes to your PR so that we can merge it?
just do it
@tough imp
AG said he was gonna be gone for like 3 weeks, and we don't want a PR just sitting stale for that long
just do it
just did it
nice
@tough imp thanks a lot .
please use hyperlink for testing not message id . cuz it was made for hyperlink
The point of the Message converter is that it accepts both
@molten bough Think you could have a look at these? As I understand it's just you and lemon really involved in there projects https://github.com/python-discord/django-simple-bulma/pull/36 https://github.com/python-discord/django-crispy-bulma/pull/29
Also, can you disable check_suite on simple and crispy bulma please?
@molten bough @tawdry vapor I responded to those now
I don't know what check_suite is, @green oriole, but maybe you can make that PR yourself, explaining the why and how in the PR text?
check_suite is a webhook category I think


