Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add retry and cache features to solve the problem that always shutdown accidently after running for a few hours #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wa008
Copy link

@wa008 wa008 commented Jul 19, 2024

When I run the code and migrate about 72000 message from to slack to discord, I found it always shutdown after running three to five hours due to the network stability or other unknow question, so, I try to add retry and cache feature to it, it can retry from last migrate point, it works fine for my case.

Sorry for my free code style, I total understand if this PR can not be merged.
If you have other question, feel free to contact me.

@pR0Ps
Copy link
Owner

pR0Ps commented Jul 19, 2024

I'm not able to merge this as-is, but it's great idea and proof of concept so thanks for sharing it!

Instead of the retrying being done by using an external cache file and running the program multiple times, I think it might make sense to do it all within the program itself. Doing this would mean that the cache could just be kept in memory. I'll see if I can implement something along those lines.

@wa008
Copy link
Author

wa008 commented Jul 19, 2024

I'm not able to merge this as-is, but it's great idea and proof of concept so thanks for sharing it!

Instead of the retrying being done by using an external cache file and running the program multiple times, I think it might make sense to do it all within the program itself. Doing this would mean that the cache could just be kept in memory. I'll see if I can implement something along those lines.

I have tried add retry feature into the memory, But it doesn't work.

That will be definitely great if adding feature into memery works.

@pR0Ps
Copy link
Owner

pR0Ps commented Jul 19, 2024

I was going to add the retry logic in run_import so it will fully disconnect and reconnect the client when it retries. Eg. putting a loop around this section of code:

__log__.info("Logging the bot into Discord")
client = SlackImportClient(data_dir=t, **kwargs)
client.run(token, reconnect=False, log_handler=None)
if client._exception:
raise client._exception

Do you think that would work?

@wa008
Copy link
Author

wa008 commented Jul 19, 2024

I was going to add the retry logic in run_import so it will fully disconnect and reconnect the client when it retries. Eg. putting a loop around this section of code:

__log__.info("Logging the bot into Discord")
client = SlackImportClient(data_dir=t, **kwargs)
client.run(token, reconnect=False, log_handler=None)
if client._exception:
raise client._exception

Do you think that would work?

I don't think that works based on my recent attempts in the past two days

Actually, I tried to add retry for main() function, But I found it still doesn't work.

if __name__ == "__main__":
    main()

https://github.com/pR0Ps/slack-to-discord/blob/master/slack_to_discord/__main__.py#L38

This was definitely strange problem.

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

Successfully merging this pull request may close these issues.

2 participants