Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Bot does not stop with Ctrl+C? #27

Open
Jsalaz1989 opened this issue Jun 6, 2022 · 7 comments
Open

Bot does not stop with Ctrl+C? #27

Jsalaz1989 opened this issue Jun 6, 2022 · 7 comments

Comments

@Jsalaz1989
Copy link

Hello,

I have the typical loop in my file:

def main():
	bot_controller = defineBot(bot_config)

	while True:
		try:
			bot_controller.executeBot()
		except KeyboardInterrupt:
			return

		sleep(15)

However, when I hit ctrl+c the terminal appears to react but not actually stop the program:
image

Am I misunderstanding something?

Thanks

@Jsalaz1989
Copy link
Author

tudor pls

@tudorelu
Copy link
Owner

Hey hey, so you see how 'sleep(15)' is outside the scope of 'try'? You want to put it inside, so the KeyboardInterrupt will work while the bot is waiting.

try:
    bot_controller.executeBot()
    sleep(15)
except KeyboardInterrupt:
    return

@Jsalaz1989
Copy link
Author

Jsalaz1989 commented Jun 16, 2022

That's like the first thing I tried. If I bring in the sleep(15) inside the try it won't even react to the Ctrl+C. The terminal never stops showing the "Executed the bot loop. Now waiting...". The following screenshot is after trying to send Ctrl+C multiple times to the terminal.

image

@tudorelu
Copy link
Owner

@Jsalaz1989
Copy link
Author

I think it's more of an issue with your logging of "Executed the bot loop. Now waiting...". Look at this:

image

After ctrl+c the first time you can see it prints the "inside except". However, after that, your logging is still spinning with the "Executed the bot loop. Now waiting..." and even if I try ctrl+c again, it doesn´t react in any way.

@tudorelu
Copy link
Owner

Oh that makes sense, it's probably to do with yaspin (the spinner/logger)

@Jsalaz1989
Copy link
Author

While you're looking into that, would it also make sense to look into the following?

When the bot places a sell order, it repeatedly prints out "OPEN SELL order on...":

image

It just keeps filling up the terminal with it. Wouldn´t it be better to just print it once and then if anything new happens, print the new change?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants