pR0Ps / slack-to-discord

Import a Slack export into a Discord server
https://pypi.org/project/slack-to-discord/
76 stars 11 forks source link

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

Open wa008 opened 1 month ago

wa008 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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: https://github.com/pR0Ps/slack-to-discord/blob/5fb8c39600224885030696d62b89e63a36030fa3/slack_to_discord/importer.py#L575-L579

Do you think that would work?

wa008 commented 1 month ago

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:

https://github.com/pR0Ps/slack-to-discord/blob/5fb8c39600224885030696d62b89e63a36030fa3/slack_to_discord/importer.py#L575-L579

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.