#๐Ÿ”’ Asyncio Server Problem

107 messages ยท Page 1 of 1 (latest)

median daggerBOT
#

@frosty grove

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

frosty grove
#

Once again, server runs fine, 0 issues. Suddenly, i'll see it stops receving incoming connections for no apparent reason.

#

When i cntrl C, no unhandled exceptions or anything unexpected

#

@trail raven

#

Dont wanna bother u, but ur smart

#

and im on the verge of a meltdown

dawn plover
#
    asyncio.create_task(tick()), await asyncio.Event().wait()
``` you should probably hold a strong reference to the tick task
#

or use a TaskGroup

frosty grove
#

for no i need to know whats causing this problem

#

and thats not it

dawn plover
#

having blank excepts will prevent exceptions from propagating

dawn plover
frosty grove
#

cus i just added that

dawn plover
#

the GC could be collecting that task and killing everything

frosty grove
#

and it was different before

#

it was different before

#

and had same issues

#

it was this before

hearty spruce
frosty grove
#

i used to do that

#

also didnt change much

#

but i'll add it anyways

#

just to see

hearty spruce
#

I just assume there's some resource leak, if it's 'fails after n minutes', so look at any cleanup.

frosty grove
#

thanks man, any help is so good rn

#

cus im so tired

frosty grove
#

i have a feeling it has something to do with start

#

idk

#

all i know is the coroutine isnt being cancelled.

#

its super strange man

hearty spruce
#

I'll refer you to nedbat's wisdom: #python-discussion message

frosty grove
#

i dont wanna be rude to him.

#

oh u mean the message

#

lmao

#

i thought u meant him

trail raven
#

what seems to be the prob

frosty grove
#

I should add that it once actually died like less than a minute after running

trail raven
#

did you add the canary task like I asked you to?

frosty grove
#

no

trail raven
#

why?

frosty grove
#

cus idk what that is

#

and im not sure if its needed

trail raven
#

I explained it to you

frosty grove
#

often the mistakes i make are stupid

trail raven
#

and why you need it

#

you need it so that when it stops outputting text, you know the event loop is stuck

frosty grove
#

will canary task show me exactly where it when wrong

trail raven
#

no, but it will confirm that the event loop is stuck

frosty grove
frosty grove
#

im waiting for something to go wrong again

#

and ill see

trail raven
#

well, there is a way to get a stack trace from another thread

#

so if you detect, from another thread, that the event loop is stuck, you can use this technique to find out what the event loop thread is doing

#

do you have your current code up somewhere?

#

sys._current_frames() is the key function here

frosty grove
#

^

#

@trail raven

#

ok ye

#

@trail raven

#

its the event loop altogether

trail raven
#

that's your old code, from when you opened this help channel?

trail raven
#

it's still spawning threads

frosty grove
#

i dont use threads

#

at all

#

btw

#

for this

#

or threading

#

i removed it like u told me to

trail raven
#

well, I just opened the pastes you linked to

#

and there are threads

frosty grove
#

send pic

trail raven
#

that picture tells me nothing

frosty grove
#

for what tho

#

for dns servers

#

yes

trail raven
#

I want to see what we're working with

frosty grove
#

thats unrelated

frosty grove
trail raven
#

what do I mean? you have a problem with code, so maybe let me see what that code looks like?

frosty grove
#

here

trail raven
#

you really should either store the tasks somewhere or use a task group

frosty grove
#

bro

#

im trying to figure out whats going on with these event loop rn

trail raven
frosty grove
#

oh

#

lols

#

see

trail raven
#

reading the docs helps, sometimes

frosty grove
#

dumb mistake

#

this doesnt include asyncio.run()?

#

right

trail raven
#

right

#

task groups make this easy

#

and they also ensure that exceptions aren't lost

#

if you can't upgrade to Python 3.12 (where asyncio.TaskGroupis available), you can use AnyIO and its create_task_group()

frosty grove
#

Thank you so much btw

trail raven
#

np

median daggerBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Asyncio Server Problem