MCPcopy Create free account
hub / github.com/wal-e/wal-e / put

Method put

wal_e/worker/upload_pool.py:71–113  ·  view source on GitHub ↗

Upload a tar volume Blocks if there is too much work outstanding already, and raise errors of previously submitted greenlets that die unexpectedly.

(self, tpart)

Source from the content-addressed store, hash-verified

69 self.concurrency_burden -= 1
70
71 def put(self, tpart):
72 """Upload a tar volume
73
74 Blocks if there is too much work outstanding already, and
75 raise errors of previously submitted greenlets that die
76 unexpectedly.
77 """
78 if self.closed:
79 raise UserCritical(msg='attempt to upload tar after closing',
80 hint='report a bug')
81
82 while True:
83 too_many = (
84 self.concurrency_burden + 1 > self.max_concurrency
85 or self.member_burden + len(tpart) > self.max_members
86 )
87
88 if too_many:
89 # If there are not enough resources to start an upload
90 # even with zero uploads in progress, then something
91 # has gone wrong: the user should not be given enough
92 # rope to hang themselves in this way.
93 if self.concurrency_burden == 0:
94 raise UserCritical(
95 msg=('not enough resources in pool to '
96 'support an upload'),
97 hint='report a bug')
98
99 # _wait blocks until an upload finishes and clears its
100 # used resources, after which another attempt to
101 # evaluate scheduling resources for another upload
102 # might be worth evaluating.
103 #
104 # Alternatively, an error was encountered in a
105 # previous upload in which case it'll be raised here
106 # and cause the process to regard the upload as a
107 # failure.
108 self._wait()
109 gc.collect()
110 else:
111 # Enough resources available: commence upload
112 self._start(tpart)
113 return
114
115 def join(self):
116 """Wait for uploads to exit, raising errors as necessary."""

Callers 12

deleteMethod · 0.80
_finishMethod · 0.80
_complete_executionMethod · 0.80
test_simpleFunction · 0.80
test_simple_concurrencyFunction · 0.80
test_fault_midstreamFunction · 0.80
test_fault_joinFunction · 0.80
test_put_after_joinFunction · 0.80

Calls 3

_waitMethod · 0.95
_startMethod · 0.95
UserCriticalClass · 0.90

Tested by 8

test_simpleFunction · 0.64
test_simple_concurrencyFunction · 0.64
test_fault_midstreamFunction · 0.64
test_fault_joinFunction · 0.64
test_put_after_joinFunction · 0.64