Skip to content

Commit

Permalink
Fixed lock test pep8 problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
dotsdl committed Jul 28, 2015
1 parent 6f05ca7 commit b5a7116
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
5 changes: 3 additions & 2 deletions datreant/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ def _start_logger(self, logger):
'{}'.format(self.__class__.__name__))
self.logger.setLevel(logging.INFO)

if not any([isinstance(x, logging.StreamHandler)
if not any([isinstance(x, logging.StreamHandler)
for x in self.logger.handlers]):
ch = logging.StreamHandler(sys.stdout)
cf = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
cf = logging.Formatter(
'%(name)-12s: %(levelname)-8s %(message)s')
ch.setFormatter(cf)
self.logger.addHandler(ch)
else:
Expand Down
18 changes: 5 additions & 13 deletions tests/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,32 @@

from datreant.persistence import TreantFile


@pytest.fixture
def treantfile(tmpdir):
with tmpdir.as_cwd():
tf = TreantFile('testtreantfile.h5')
return tf


def pokefile(treantfilepath, string):
"""Add two tags, then delete a tag, directly from a TreantFile"""
treantfile = TreantFile(treantfilepath)

#for i in range(2):
# tag = "{}_{}".format(string, i)
# treantfile.add_tags(tag)

treantfile._open_w()
treantfile.logger.info("task {}, fd {}".format(string, treantfile.handle.fileno()))
treantfile.logger.info(
"task {}, fd {}".format(string, treantfile.handle.fileno()))
treantfile._close()

#treantfile.add_tags("task_{}".format(string))

treantfile.add_tags(*["{}_{}".format(string, i) for i in range(1000)])

#treantfile.del_tags(random.choice(list(treantfile.get_tags())))

def test_death_by_1000_pokes(treantfile):
#for i in xrange(2):
# pokefile(treantfile.filename, "run_{}".format(i))
#mp.set_start_method('spawn')
pool = mp.Pool(processes=4)
for i in range(12):
pool.apply_async(pokefile, args=(treantfile.filename,
pool.apply_async(pokefile, args=(treantfile.filename,
"run_{}".format(i)))
pool.close()
pool.join()

assert len(treantfile.get_tags()) == 12000
#assert len(treantfile.get_tags()) == 1000

0 comments on commit b5a7116

Please sign in to comment.