#๐Ÿ”’ how to properly close a script? without memory leaks or hidden background processes?

28 messages ยท Page 1 of 1 (latest)

fluid plumeBOT
#

@still wasp

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.

wary elk
#

Most things should close themselves when your script quits.

If you've dispatched subprocesses, they need to be waited for, or tidies up, or ok to keep running - they're outside the Python interpreter's scope.

#

Threads will be joined by Python before it quits anyway (so they do need to be told to stop) except for daemon threads, which Python will terminate.

still wasp
#

so i just keep it as is ?

#

is root.quit better than root.destroy?

wary elk
wary elk
fluid plumeBOT
#

Hey @still wasp!

Please edit your message to use a code block

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
still wasp
#

im afraid of threading, pymem, and tkinter

wary elk
#

You'll have to make your own decisions about how the subprocesses are handled.

#

What are you using the threads for?

still wasp
#

to auto update

#

running the script after editing it over and over again

#

kinda slows down my pc sometimes

#

so thats why i want an efficient exit

wary elk
#

root.destroy() just removes the root window and its descendands. root.quit() quits the GUI mainloop.

Exiting your programme should do both for you automatically.

Bookmark this page: https://tkdocs.com/shipman/universal.html

wary elk
still wasp
#

i just bookmarked

#

yes

#

because i have it close and open

wary elk
#

You should probably show the threads code.

#

If it's just sitting there waiting for changes, you could make it a daemon thread, then Python will tidy it up.

still wasp
#

i see

#

im looking at the page you linked me

wary elk
#

I know nothing about pymem.

still wasp
#

it answers alot of questions

fluid plumeBOT
#
Python help channel closed using Discord native close action

This help channel has been closed. 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.