Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
e454ce4d
Commit
e454ce4d
authored
May 09, 2019
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ResourceWarnings seen during testing, and a testrunner orphaned thread warning.
Fixes #266
parent
cf15ac88
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
45 deletions
+56
-45
doc/reference/storages.rst
doc/reference/storages.rst
+1
-0
src/ZODB/scripts/repozo.py
src/ZODB/scripts/repozo.py
+50
-43
src/ZODB/tests/testThreadedShutdown.py
src/ZODB/tests/testThreadedShutdown.py
+5
-2
No files found.
doc/reference/storages.rst
View file @
e454ce4d
...
@@ -131,6 +131,7 @@ Demo storages are configured using the ``demostorage`` section::
...
@@ -131,6 +131,7 @@ Demo storages are configured using the ``demostorage`` section::
'base.fs'
'base.fs'
>>> storage.changes.getName()
>>> storage.changes.getName()
'Changes'
'Changes'
>>> storage.close()
``demostorage`` sections can contain up to 2 storage subsections,
``demostorage`` sections can contain up to 2 storage subsections,
named ``base`` and ``changes``, specifying the demo storage's base and
named ``base`` and ``changes``, specifying the demo storage's base and
...
...
src/ZODB/scripts/repozo.py
View file @
e454ce4d
...
@@ -667,9 +667,11 @@ def do_recover(options):
...
@@ -667,9 +667,11 @@ def do_recover(options):
repofiles
=
find_files
(
options
)
repofiles
=
find_files
(
options
)
if
not
repofiles
:
if
not
repofiles
:
if
options
.
date
:
if
options
.
date
:
raise
NoFiles
(
'No files in repository before %s'
,
options
.
date
)
raise
NoFiles
(
'No files in repository before %s'
%
(
options
.
date
,)
)
else
:
else
:
raise
NoFiles
(
'No files in repository'
)
raise
NoFiles
(
'No files in repository'
)
files_to_close
=
()
if
options
.
output
is
None
:
if
options
.
output
is
None
:
log
(
'Recovering file to stdout'
)
log
(
'Recovering file to stdout'
)
outfp
=
sys
.
stdout
outfp
=
sys
.
stdout
...
@@ -682,51 +684,56 @@ def do_recover(options):
...
@@ -682,51 +684,56 @@ def do_recover(options):
log
(
'Recovering file to %s'
,
options
.
output
)
log
(
'Recovering file to %s'
,
options
.
output
)
temporary_output_file
=
options
.
output
+
'.part'
temporary_output_file
=
options
.
output
+
'.part'
outfp
=
open
(
temporary_output_file
,
'wb'
)
outfp
=
open
(
temporary_output_file
,
'wb'
)
if
options
.
withverify
:
files_to_close
+=
(
outfp
,)
datfile
=
os
.
path
.
splitext
(
repofiles
[
0
])[
0
]
+
'.dat'
with
open
(
datfile
)
as
fp
:
truth_dict
=
{}
for
line
in
fp
:
fn
,
startpos
,
endpos
,
sum
=
line
.
split
()
startpos
=
int
(
startpos
)
endpos
=
int
(
endpos
)
filename
=
os
.
path
.
join
(
options
.
repository
,
os
.
path
.
basename
(
fn
))
truth_dict
[
filename
]
=
{
'size'
:
endpos
-
startpos
,
'sum'
:
sum
,
}
totalsz
=
0
for
repofile
in
repofiles
:
reposz
,
reposum
=
concat
([
repofile
],
outfp
)
expected_truth
=
truth_dict
[
repofile
]
if
reposz
!=
expected_truth
[
'size'
]:
raise
VerificationFail
(
"%s is %d bytes, should be %d bytes"
%
(
repofile
,
reposz
,
expected_truth
[
'size'
]))
if
reposum
!=
expected_truth
[
'sum'
]:
raise
VerificationFail
(
"%s has checksum %s instead of %s"
%
(
repofile
,
reposum
,
expected_truth
[
'sum'
]))
totalsz
+=
reposz
log
(
"Recovered chunk %s : %s bytes, md5: %s"
,
repofile
,
reposz
,
reposum
)
log
(
"Recovered a total of %s bytes"
,
totalsz
)
else
:
reposz
,
reposum
=
concat
(
repofiles
,
outfp
)
log
(
'Recovered %s bytes, md5: %s'
,
reposz
,
reposum
)
if
options
.
output
is
not
None
:
try
:
last_base
=
os
.
path
.
splitext
(
repofiles
[
-
1
])[
0
]
if
options
.
withverify
:
source_index
=
'%s.index'
%
last_base
datfile
=
os
.
path
.
splitext
(
repofiles
[
0
])[
0
]
+
'.dat'
target_index
=
'%s.index'
%
options
.
output
with
open
(
datfile
)
as
fp
:
if
os
.
path
.
exists
(
source_index
):
truth_dict
=
{}
log
(
'Restoring index file %s to %s'
,
source_index
,
target_index
)
for
line
in
fp
:
shutil
.
copyfile
(
source_index
,
target_index
)
fn
,
startpos
,
endpos
,
sum
=
line
.
split
()
startpos
=
int
(
startpos
)
endpos
=
int
(
endpos
)
filename
=
os
.
path
.
join
(
options
.
repository
,
os
.
path
.
basename
(
fn
))
truth_dict
[
filename
]
=
{
'size'
:
endpos
-
startpos
,
'sum'
:
sum
,
}
totalsz
=
0
for
repofile
in
repofiles
:
reposz
,
reposum
=
concat
([
repofile
],
outfp
)
expected_truth
=
truth_dict
[
repofile
]
if
reposz
!=
expected_truth
[
'size'
]:
raise
VerificationFail
(
"%s is %d bytes, should be %d bytes"
%
(
repofile
,
reposz
,
expected_truth
[
'size'
]))
if
reposum
!=
expected_truth
[
'sum'
]:
raise
VerificationFail
(
"%s has checksum %s instead of %s"
%
(
repofile
,
reposum
,
expected_truth
[
'sum'
]))
totalsz
+=
reposz
log
(
"Recovered chunk %s : %s bytes, md5: %s"
,
repofile
,
reposz
,
reposum
)
log
(
"Recovered a total of %s bytes"
,
totalsz
)
else
:
else
:
log
(
'No index file to restore: %s'
,
source_index
)
reposz
,
reposum
=
concat
(
repofiles
,
outfp
)
log
(
'Recovered %s bytes, md5: %s'
,
reposz
,
reposum
)
if
outfp
!=
sys
.
stdout
:
if
options
.
output
is
not
None
:
outfp
.
close
()
last_base
=
os
.
path
.
splitext
(
repofiles
[
-
1
])[
0
]
source_index
=
'%s.index'
%
last_base
target_index
=
'%s.index'
%
options
.
output
if
os
.
path
.
exists
(
source_index
):
log
(
'Restoring index file %s to %s'
,
source_index
,
target_index
)
shutil
.
copyfile
(
source_index
,
target_index
)
else
:
log
(
'No index file to restore: %s'
,
source_index
)
finally
:
for
f
in
files_to_close
:
f
.
close
()
if
options
.
output
is
not
None
:
try
:
try
:
os
.
rename
(
temporary_output_file
,
options
.
output
)
os
.
rename
(
temporary_output_file
,
options
.
output
)
except
OSError
:
except
OSError
:
...
...
src/ZODB/tests/testThreadedShutdown.py
View file @
e454ce4d
...
@@ -37,6 +37,9 @@ class ShutdownTest(ZODB.tests.util.TestCase):
...
@@ -37,6 +37,9 @@ class ShutdownTest(ZODB.tests.util.TestCase):
'ZODBTests.fs'
,
create
=
1
)
'ZODBTests.fs'
,
create
=
1
)
self
.
_db
=
ZODB
.
DB
(
self
.
_storage
)
self
.
_db
=
ZODB
.
DB
(
self
.
_storage
)
def
tearDown
(
self
):
ZODB
.
tests
.
util
.
TestCase
.
tearDown
(
self
)
def
check_shutdown
(
self
):
def
check_shutdown
(
self
):
client_thread
=
ZODBClientThread
(
self
.
_db
,
self
)
client_thread
=
ZODBClientThread
(
self
.
_db
,
self
)
client_thread
.
start
()
client_thread
.
start
()
...
@@ -47,8 +50,8 @@ class ShutdownTest(ZODB.tests.util.TestCase):
...
@@ -47,8 +50,8 @@ class ShutdownTest(ZODB.tests.util.TestCase):
# have different contents.
# have different contents.
self
.
_db
.
close
()
self
.
_db
.
close
()
def
tearDown
(
self
):
# Be sure not to 'leak' the running thread.
ZODB
.
tests
.
util
.
TestCase
.
tearDown
(
self
)
client_thread
.
join
(
)
def
test_suite
():
def
test_suite
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment