-
Notifications
You must be signed in to change notification settings - Fork 4
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
rclone: fix discard thread issues #92
base: master
Are you sure you want to change the base?
Conversation
@alexandru-bagu so you practically tested this on cygwin? Thanks for the PR! |
Yes, I did more than ~30 tests on Cygwin. |
I actually did a few more tests and it looks like borg is still hanging on thread.start() even with daemon=False. What is odd is that when the debug argument is provided it does not hang... |
For whatever random reason, when starting a second thread using threading.thread.start() the 2nd would hang. Oddly enough, when --debug is used it does not hang which means it's got to be something with a process pipe in cygwin. I will test this on Linux to make sure no bugs are introduced. My only concern (when comparing Windows with Linux) is that in Linux I know one can get an error with a port being in used because Linux keeps ports for a while even when the socket is closed. I attempted to fix this by using |
9b2d4b8
to
df7a25f
Compare
I tested on a Oracle Linux 8.10 the changes and had to make one adjustment. On Windows urllib3 has a bigger timeout for starting a http request whilst on Linux it would instantly fail because rclone was not yet listening to the given port. As such I am waiting for the port to become available before trying the noop request. This version seems to work fine for both OS. |
df7a25f
to
28b25f7
Compare
… on relying on rclone to pick one; add a way to specify the path to the rclone binary for custom installations
28b25f7
to
7693b04
Compare
I opted not to catch an error now for |
9045282
to
1350810
Compare
1350810
to
99583d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nitpicks.
@ncw Can you have a look, please? |
I am actually wondering if it wouldn't be a good idea just to add an environment variable with a port to be used for rclone. If for some reason the port is already in use, then the user can decide whether to use another one or not. That way we can also get rid of the while loop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks reasonable to me.
If duplicating the find an open port code in Python lets us lose a thread then that is probably a good tradeoff as Python and threads aren't my favourite sandwich filling.
Though I'll note that the detection of an open port is racy - there is opportunity for another process to take it in between python closing it and rclone opening it. I think it is unlikely though.
I probably wouldn't bother with a variable to set a port number - that will break as soon as the user runs two copies of rclone.
@@ -66,7 +67,7 @@ class Rclone(BackendBase): | |||
""" | |||
|
|||
precreate_dirs: bool = False | |||
HOST = "localhost" | |||
HOST = "127.0.0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just note here that it is possible for 127.0.0.1
not to exist on IPv6 only computers... localhost
should map to ::0
in that case. But then again there are probably computers where localhost
doesn't work too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wondered about the localhost change. @alexandru-bagu was there a specific reason why you changed that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remember the exact reason right now but I remember that when I was checking if the port was bound, the check would fail even though rclone was listening to the specified port.
It might be a Cygwin issue only and an option could be to allow the user to specify the hostname for binding the socket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so guess we'll leave that "as is".
I considered this and I did a noop check. If that fails another port is considered. This will ensure that rclone or a software that implements rclone rc protocol would respond with a valid response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Tell me when ready, so I can merge it.
This PR fixes two issues: