B2_Command_Line_Tool icon indicating copy to clipboard operation
B2_Command_Line_Tool copied to clipboard

Sync no longer terminates

Open mohmad-null opened this issue 8 years ago • 4 comments

I have a backup script that has been running happily for about 6 months. Several weeks ago I updated the libraries, including Twisted and B2 to the latest versions. (still Python 3.5) Since then, whenever a large file has been synced, the file uploads fine, but the script no longer terminates, it hangs waiting for the large file to finish transferring (it has finished, the content is all there and fine, it just... waits).

Small files are fine.

Has there been some intentional change in the sync code that I'm now misusing, or is this likely to be a regression?

My usage of sync_folders (from b2.sync) looks like this:

	source = parse_sync_folder(pc_source_dir, b2_api)

	# Destination is a bucket
	destination = parse_sync_folder('b2://' + b2_bucket_name, b2_api)

	args = PointlessParameters()

	# Here we capture the output of sys.stdout into temp_std_out
	# This is so we can print to screen and log.
	# We disable progress (no_progress=True) so we don't get lots of progress updates in the log file.
	# Newline = None because otherwise it won't print anything (I think the code is using /r as newline)
	temp_std_out = StringIO(newline=None)
	with redirect_stdout(temp_std_out):
		# Do the syncronisation
		sync_folders(
			source_folder=source,
			dest_folder=destination,
			args=args,
			now_millis=current_time_millis(),
			stdout=sys.stdout,
			no_progress=True,
			max_workers=B2_NUM_THREADS
		)

mohmad-null avatar May 07 '17 19:05 mohmad-null

We haven't changed the sync code for quite a while.

What platform are you running on? I would expect the code to use \n for newlines, unless you're running on Windows, where it might use \r\n.

Would it be possible to get a backtrace at the point where it's stuck?

bwbeach avatar May 07 '17 22:05 bwbeach

@mohmad-null see how to stop the twisted reactor here, maybe it helps you?

ppolewicz avatar May 08 '17 02:05 ppolewicz

As mentioned, I did update the twisted library as well, so maybe they changed something that introduced this. I think from 16.something to 17.1 which is what I have now.

@bwbeach - I am indeed running this on a Windows platform, though I doubt that the newline thing is a problem (it was there when the code was running fine too). I'm afraid I wouldn't know how to get a backtrace at the point it's sticking ... the code is just hanging there so how would you trigger the backtrace?

@ppolewicz - I've never touched twisted before, what would I do with that?

mohmad-null avatar May 09 '17 21:05 mohmad-null

As far as I've seen in tutorials, Twisted runs an infinite event loop (which hangs forever). You need to shut it down explicitly to terminate your program (as in the link I posted).

ppolewicz avatar May 10 '17 00:05 ppolewicz

Please reopen if problem still occurs with the current version

mjurbanski-reef avatar Nov 10 '23 08:11 mjurbanski-reef