Skip to content
Community
#run
3
RESOURCES
TheDrone7
Welcome to Replit Community [+ Rules]
TheDrone7
EVENTS
TOP TAGS
#games
93
#apps
23
#python
24.7K
#javascript
8.9K
#html
8.4K
#fun
4.1K
#game
3.6K
#simple
3.3K
#python3
2.6K
#java
2K
#cpp
1.8K
#bash
1.1K
hankertrix
hankertrix
published a Post
3 months ago
Exit Demonstration
Exit Demonstration
How do I make the run button call a function when the script is done running?
The repl here shows how the green run button in replit fails to call the exitcallback function which prints "Goodbye". However, when running the file using bash, using python3 main.py the exitcallback function is correctly called. You can try it by using runshell() in the console. Also, no, I can't use the runshell() function in place of the main() function, the repl will just fail to run properly. Is there any way to configure the run button so that the exit_callback function is called when the script exits? Or is this a bug I should report?
hankertrix
hankertrix @Highwayman I tinkered with the args and it seems that I can't remove any of the args without the repl process crashing. However, removing all the code related to the interpreter seems to have fixed the issue. I'm guessing it's because of using replit's prybar interface that causes Python to not register any exit handlers, since running it using a normal bash shell seems to work fine. I'm guessing most non-nix repls will use the prybar interface by default unless you configure the run button otherwise in the `.replit` file. Thank you so much for your help! I think this should be reported as a bug for prybar.2 months ago
Highwayman
Highwayman @hankertrix I'm glad to be of assistance :P There is a [feedback form](http://replit.com/support) for replit when you get bugs - thats probably the best place to post it. I've contacted them before I'm pretty sure and they're pretty responsive. :)2 months ago
hankertrix
hankertrix @Highwayman Thanks for the link! I'll send them a bug report in a bit.2 months ago
#ask
#help
#python
+2
Load more