rclone: fix discard thread issues#92
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
|
@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. |
ncw
left a comment
There was a problem hiding this comment.
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.
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. |
ThomasWaldmann
left a comment
There was a problem hiding this comment.
LGTM. Tell me when ready, so I can merge it.
|
I did tests with a thread-pool with long-lived threads that would be kept until the program exits and there is room for concurrency improvements but I would leave this in another PR. |
|
While developing an s3 backend for borgstore, I found that the exception thrown in |
7ee0c18 to
3ec4fff
Compare
|
I moved the regex check before raising the exceptions. I believe we should still raise exceptions if rclone is required but is not available or is too old. |
|
@alexandru-bagu Thanks! |
This PR fixes two issues: