summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2014-11-13 13:31:32 +0100
committerSebastian Thiel <byronimo@gmail.com>2014-11-13 13:31:32 +0100
commitbf942a913d69eb2079f9e82888aaccf2f6222643 (patch)
tree6b9489af08a47c52d9b61be628beb412eb7d934a
parentb64c771bcb2ec336dd549cfe9d072340c886f3c9 (diff)
downloadgitdb-bf942a913d69eb2079f9e82888aaccf2f6222643.tar.gz
Fully removed all async dependencies
-rw-r--r--.gitmodules3
-rw-r--r--doc/source/changes.rst7
-rw-r--r--gitdb/__init__.py4
-rw-r--r--gitdb/db/base.py55
-rw-r--r--gitdb/db/mem.py8
-rw-r--r--gitdb/db/pack.py4
m---------gitdb/ext/async0
-rw-r--r--gitdb/test/__init__.py12
-rw-r--r--gitdb/test/db/lib.py83
-rw-r--r--gitdb/test/db/test_git.py1
-rw-r--r--gitdb/test/db/test_loose.py1
-rw-r--r--gitdb/test/performance/test_stream.py90
-rw-r--r--gitdb/test/test_example.py23
-rw-r--r--gitdb/util.py10
-rwxr-xr-xsetup.py6
15 files changed, 14 insertions, 293 deletions
diff --git a/.gitmodules b/.gitmodules
index 9781053..d85b15c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
-[submodule "async"]
- path = gitdb/ext/async
- url = https://github.com/gitpython-developers/async.git
[submodule "smmap"]
path = gitdb/ext/smmap
url = https://github.com/Byron/smmap.git
diff --git a/doc/source/changes.rst b/doc/source/changes.rst
index 839bf16..f544f76 100644
--- a/doc/source/changes.rst
+++ b/doc/source/changes.rst
@@ -3,6 +3,13 @@ Changelog
#########
*****
+0.6.0
+*****
+
+* Added support got python 3.X
+* Removed all `async` dependencies and all `*_async` versions of methods with it.
+
+*****
0.5.4
*****
* Adjusted implementation to use the SlidingMemoryManager by default in python 2.6 for efficiency reasons. In Python 2.4, the StaticMemoryManager will be used instead.
diff --git a/gitdb/__init__.py b/gitdb/__init__.py
index 72b5ab0..165993f 100644
--- a/gitdb/__init__.py
+++ b/gitdb/__init__.py
@@ -10,7 +10,7 @@ import os
#{ Initialization
def _init_externals():
"""Initialize external projects by putting them into the path"""
- for module in ('async', 'smmap'):
+ for module in ('smmap',):
sys.path.append(os.path.join(os.path.dirname(__file__), 'ext', module))
try:
@@ -27,7 +27,7 @@ _init_externals()
__author__ = "Sebastian Thiel"
__contact__ = "byronimo@gmail.com"
__homepage__ = "https://github.com/gitpython-developers/gitdb"
-version_info = (0, 5, 5)
+version_info = (0, 6, 0)
__version__ = '.'.join(str(i) for i in version_info)
diff --git a/gitdb/db/base.py b/gitdb/db/base.py
index c534705..eac54ec 100644
--- a/gitdb/db/base.py
+++ b/gitdb/db/base.py
@@ -4,7 +4,6 @@
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
"""Contains implementations of database retrieveing objects"""
from gitdb.util import (
- pool,
join,
LazyMixin,
hex_to_bin
@@ -15,10 +14,6 @@ from gitdb.exc import (
AmbiguousObjectName
)
-from async import (
- ChannelThreadTask
-)
-
from itertools import chain
from functools import reduce
@@ -41,47 +36,18 @@ class ObjectDBR(object):
binary sha is contained in the database"""
raise NotImplementedError("To be implemented in subclass")
- def has_object_async(self, reader):
- """Return a reader yielding information about the membership of objects
- as identified by shas
- :param reader: Reader yielding 20 byte shas.
- :return: async.Reader yielding tuples of (sha, bool) pairs which indicate
- whether the given sha exists in the database or not"""
- task = ChannelThreadTask(reader, str(self.has_object_async), lambda sha: (sha, self.has_object(sha)))
- return pool.add_task(task)
-
def info(self, sha):
""" :return: OInfo instance
:param sha: bytes binary sha
:raise BadObject:"""
raise NotImplementedError("To be implemented in subclass")
- def info_async(self, reader):
- """Retrieve information of a multitude of objects asynchronously
- :param reader: Channel yielding the sha's of the objects of interest
- :return: async.Reader yielding OInfo|InvalidOInfo, in any order"""
- task = ChannelThreadTask(reader, str(self.info_async), self.info)
- return pool.add_task(task)
-
def stream(self, sha):
""":return: OStream instance
:param sha: 20 bytes binary sha
:raise BadObject:"""
raise NotImplementedError("To be implemented in subclass")
- def stream_async(self, reader):
- """Retrieve the OStream of multiple objects
- :param reader: see ``info``
- :param max_threads: see ``ObjectDBW.store``
- :return: async.Reader yielding OStream|InvalidOStream instances in any order
-
- **Note:** depending on the system configuration, it might not be possible to
- read all OStreams at once. Instead, read them individually using reader.read(x)
- where x is small enough."""
- # base implementation just uses the stream method repeatedly
- task = ChannelThreadTask(reader, str(self.stream_async), self.stream)
- return pool.add_task(task)
-
def size(self):
""":return: amount of objects in this database"""
raise NotImplementedError()
@@ -129,27 +95,6 @@ class ObjectDBW(object):
:raise IOError: if data could not be written"""
raise NotImplementedError("To be implemented in subclass")
- def store_async(self, reader):
- """
- Create multiple new objects in the database asynchronously. The method will
- return right away, returning an output channel which receives the results as
- they are computed.
-
- :return: Channel yielding your IStream which served as input, in any order.
- The IStreams sha will be set to the sha it received during the process,
- or its error attribute will be set to the exception informing about the error.
-
- :param reader: async.Reader yielding IStream instances.
- The same instances will be used in the output channel as were received
- in by the Reader.
-
- **Note:** As some ODB implementations implement this operation atomic, they might
- abort the whole operation if one item could not be processed. Hence check how
- many items have actually been produced."""
- # base implementation uses store to perform the work
- task = ChannelThreadTask(reader, str(self.store_async), self.store)
- return pool.add_task(task)
-
#} END edit interface
diff --git a/gitdb/db/mem.py b/gitdb/db/mem.py
index a224546..1aa0d51 100644
--- a/gitdb/db/mem.py
+++ b/gitdb/db/mem.py
@@ -32,10 +32,7 @@ class MemoryDB(ObjectDBR, ObjectDBW):
"""A memory database stores everything to memory, providing fast IO and object
retrieval. It should be used to buffer results and obtain SHAs before writing
it to the actual physical storage, as it allows to query whether object already
- exists in the target storage before introducing actual IO
-
- **Note:** memory is currently not threadsafe, hence the async methods cannot be used
- for storing"""
+ exists in the target storage before introducing actual IO"""
def __init__(self):
super(MemoryDB, self).__init__()
@@ -62,9 +59,6 @@ class MemoryDB(ObjectDBR, ObjectDBW):
return istream
- def store_async(self, reader):
- raise UnsupportedOperation("MemoryDBs cannot currently be used for async write access")
-
def has_object(self, sha):
return sha in self._cache
diff --git a/gitdb/db/pack.py b/gitdb/db/pack.py
index 4d0a7f8..eaf431a 100644
--- a/gitdb/db/pack.py
+++ b/gitdb/db/pack.py
@@ -125,10 +125,6 @@ class PackedDB(FileDBBase, ObjectDBR, CachingDB, LazyMixin):
inefficient"""
raise UnsupportedOperation()
- def store_async(self, reader):
- # TODO: add ObjectDBRW before implementing this
- raise NotImplementedError()
-
#} END object db write
diff --git a/gitdb/ext/async b/gitdb/ext/async
deleted file mode 160000
-Subproject b930ee15c029860285db60aab4913dc8a9af2cd
diff --git a/gitdb/test/__init__.py b/gitdb/test/__init__.py
index ca104c0..8a681e4 100644
--- a/gitdb/test/__init__.py
+++ b/gitdb/test/__init__.py
@@ -2,15 +2,3 @@
#
# This module is part of GitDB and is released under
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
-
-import gitdb.util
-
-#{ Initialization
-def _init_pool():
- """Assure the pool is actually threaded"""
- size = 2
- print("Setting ThreadPool to %i" % size)
- gitdb.util.pool.set_size(size)
-
-
-#} END initialization
diff --git a/gitdb/test/db/lib.py b/gitdb/test/db/lib.py
index 67958c3..962d4bc 100644
--- a/gitdb/test/db/lib.py
+++ b/gitdb/test/db/lib.py
@@ -10,8 +10,6 @@ from gitdb.test.lib import (
TestBase
)
-
-
from gitdb.stream import (
Sha1Writer,
ZippedStoreShaWriter
@@ -28,8 +26,6 @@ from gitdb.typ import str_blob_type
from gitdb.utils.encoding import force_bytes
from gitdb.utils.compat import xrange
-from async import IteratorReader
-
from io import BytesIO
from struct import pack
@@ -132,82 +128,3 @@ class TestDBBase(TestBase):
# END for each data set
# END for each dry_run mode
- def _assert_object_writing_async(self, db):
- """Test generic object writing using asynchronous access"""
- ni = 5000
- def istream_generator(offset=0, ni=ni):
- for data_src in xrange(ni):
- data = bytes(data_src + offset)
- yield IStream(str_blob_type, len(data), BytesIO(data))
- # END for each item
- # END generator utility
-
- # for now, we are very trusty here as we expect it to work if it worked
- # in the single-stream case
-
- # write objects
- reader = IteratorReader(istream_generator())
- istream_reader = db.store_async(reader)
- istreams = istream_reader.read() # read all
- assert istream_reader.task().error() is None
- assert len(istreams) == ni
-
- for stream in istreams:
- assert stream.error is None
- assert len(stream.binsha) == 20
- assert isinstance(stream, IStream)
- # END assert each stream
-
- # test has-object-async - we must have all previously added ones
- reader = IteratorReader( istream.binsha for istream in istreams )
- hasobject_reader = db.has_object_async(reader)
- count = 0
- for sha, has_object in hasobject_reader:
- assert has_object
- count += 1
- # END for each sha
- assert count == ni
-
- # read the objects we have just written
- reader = IteratorReader( istream.binsha for istream in istreams )
- ostream_reader = db.stream_async(reader)
-
- # read items individually to prevent hitting possible sys-limits
- count = 0
- for ostream in ostream_reader:
- assert isinstance(ostream, OStream)
- count += 1
- # END for each ostream
- assert ostream_reader.task().error() is None
- assert count == ni
-
- # get info about our items
- reader = IteratorReader( istream.binsha for istream in istreams )
- info_reader = db.info_async(reader)
-
- count = 0
- for oinfo in info_reader:
- assert isinstance(oinfo, OInfo)
- count += 1
- # END for each oinfo instance
- assert count == ni
-
-
- # combined read-write using a converter
- # add 2500 items, and obtain their output streams
- nni = 2500
- reader = IteratorReader(istream_generator(offset=ni, ni=nni))
- istream_to_sha = lambda istreams: [ istream.binsha for istream in istreams ]
-
- istream_reader = db.store_async(reader)
- istream_reader.set_post_cb(istream_to_sha)
-
- ostream_reader = db.stream_async(istream_reader)
-
- count = 0
- # read it individually, otherwise we might run into the ulimit
- for ostream in ostream_reader:
- assert isinstance(ostream, OStream)
- count += 1
- # END for each ostream
- assert count == nni
diff --git a/gitdb/test/db/test_git.py b/gitdb/test/db/test_git.py
index 4bce7da..56899e5 100644
--- a/gitdb/test/db/test_git.py
+++ b/gitdb/test/db/test_git.py
@@ -48,4 +48,3 @@ class TestGitDB(TestDBBase):
# its possible to write objects
self._assert_object_writing(gdb)
- self._assert_object_writing_async(gdb)
diff --git a/gitdb/test/db/test_loose.py b/gitdb/test/db/test_loose.py
index 1299f7b..1d6af9c 100644
--- a/gitdb/test/db/test_loose.py
+++ b/gitdb/test/db/test_loose.py
@@ -18,7 +18,6 @@ class TestLooseDB(TestDBBase):
# write data
self._assert_object_writing(ldb)
- self._assert_object_writing_async(ldb)
# verify sha iteration and size
shas = list(ldb.sha_iter())
diff --git a/gitdb/test/performance/test_stream.py b/gitdb/test/performance/test_stream.py
index 6c8f715..929c7e5 100644
--- a/gitdb/test/performance/test_stream.py
+++ b/gitdb/test/performance/test_stream.py
@@ -7,18 +7,9 @@ from lib import TestBigRepoR
from gitdb.db import LooseObjectDB
from gitdb.stream import IStream
-from gitdb.util import (
- pool,
- bin_to_hex
-)
-from gitdb.typ import str_blob_type
+from gitdb.util import bin_to_hex
from gitdb.fun import chunk_size
-from async import (
- IteratorReader,
- ChannelThreadTask,
- )
-
from time import time
import os
import sys
@@ -43,15 +34,6 @@ def read_chunked_stream(stream):
return stream
-class TestStreamReader(ChannelThreadTask):
- """Expects input streams and reads them in chunks. It will read one at a time,
- requireing a queue chunk of size 1"""
- def __init__(self, *args):
- super(TestStreamReader, self).__init__(*args)
- self.fun = read_chunked_stream
- self.max_chunksize = 1
-
-
#} END utilities
class TestObjDBPerformance(TestBigRepoR):
@@ -119,73 +101,3 @@ class TestObjDBPerformance(TestBigRepoR):
# del db file so we keep something to do
os.remove(db_file)
# END for each randomization factor
-
-
- # multi-threaded mode
- # want two, should be supported by most of todays cpus
- pool.set_size(2)
- total_kib = 0
- nsios = len(string_ios)
- for stream in string_ios:
- stream.seek(0)
- total_kib += len(stream.getvalue()) / 1000
- # END rewind
-
- def istream_iter():
- for stream in string_ios:
- stream.seek(0)
- yield IStream(str_blob_type, len(stream.getvalue()), stream)
- # END for each stream
- # END util
-
- # write multiple objects at once, involving concurrent compression
- reader = IteratorReader(istream_iter())
- istream_reader = ldb.store_async(reader)
- istream_reader.task().max_chunksize = 1
-
- st = time()
- istreams = istream_reader.read(nsios)
- assert len(istreams) == nsios
- elapsed = time() - st
-
- print >> sys.stderr, "Threads(%i): Compressed %i KiB of data in loose odb in %f s ( %f Write KiB / s)" % (pool.size(), total_kib, elapsed, total_kib / elapsed)
-
- # decompress multiple at once, by reading them
- # chunk size is not important as the stream will not really be decompressed
-
- # until its read
- istream_reader = IteratorReader(iter([ i.binsha for i in istreams ]))
- ostream_reader = ldb.stream_async(istream_reader)
-
- chunk_task = TestStreamReader(ostream_reader, "chunker", None)
- output_reader = pool.add_task(chunk_task)
- output_reader.task().max_chunksize = 1
-
- st = time()
- assert len(output_reader.read(nsios)) == nsios
- elapsed = time() - st
-
- print >> sys.stderr, "Threads(%i): Decompressed %i KiB of data in loose odb in %f s ( %f Read KiB / s)" % (pool.size(), total_kib, elapsed, total_kib / elapsed)
-
- # store the files, and read them back. For the reading, we use a task
- # as well which is chunked into one item per task. Reading all will
- # very quickly result in two threads handling two bytestreams of
- # chained compression/decompression streams
- reader = IteratorReader(istream_iter())
- istream_reader = ldb.store_async(reader)
- istream_reader.task().max_chunksize = 1
-
- istream_to_sha = lambda items: [ i.binsha for i in items ]
- istream_reader.set_post_cb(istream_to_sha)
-
- ostream_reader = ldb.stream_async(istream_reader)
-
- chunk_task = TestStreamReader(ostream_reader, "chunker", None)
- output_reader = pool.add_task(chunk_task)
- output_reader.max_chunksize = 1
-
- st = time()
- assert len(output_reader.read(nsios)) == nsios
- elapsed = time() - st
-
- print >> sys.stderr, "Threads(%i): Compressed and decompressed and read %i KiB of data in loose odb in %f s ( %f Combined KiB / s)" % (pool.size(), total_kib, elapsed, total_kib / elapsed)
diff --git a/gitdb/test/test_example.py b/gitdb/test/test_example.py
index 433518c..aa43a09 100644
--- a/gitdb/test/test_example.py
+++ b/gitdb/test/test_example.py
@@ -9,12 +9,9 @@ from gitdb.test.lib import (
)
from gitdb import IStream
from gitdb.db import LooseObjectDB
-from gitdb.util import pool
from io import BytesIO
-from async import IteratorReader
-
class TestExamples(TestBase):
def test_base(self):
@@ -45,23 +42,3 @@ class TestExamples(TestBase):
# now the sha is set
assert len(istream.binsha) == 20
assert ldb.has_object(istream.binsha)
-
-
- # async operation
- # Create a reader from an iterator
- reader = IteratorReader(ldb.sha_iter())
-
- # get reader for object streams
- info_reader = ldb.stream_async(reader)
-
- # read one
- info = info_reader.read(1)[0]
-
- # read all the rest until depletion
- ostreams = info_reader.read()
-
- # set the pool to use two threads
- pool.set_size(2)
-
- # synchronize the mode of operation
- pool.set_size(0)
diff --git a/gitdb/util.py b/gitdb/util.py
index 8843e8c..93ba7f0 100644
--- a/gitdb/util.py
+++ b/gitdb/util.py
@@ -10,7 +10,6 @@ import errno
from io import StringIO
-from async import ThreadPool
from smmap import (
StaticWindowMapManager,
SlidingWindowMapManager,
@@ -43,15 +42,6 @@ except ImportError:
# END own unpack_from implementation
-#{ Globals
-
-# A pool distributing tasks, initially with zero threads, hence everything
-# will be handled in the main thread
-pool = ThreadPool(0)
-
-#} END globals
-
-
#{ Aliases
hex_to_bin = binascii.a2b_hex
diff --git a/setup.py b/setup.py
index 6393704..63ec5dd 100755
--- a/setup.py
+++ b/setup.py
@@ -73,7 +73,7 @@ if setuptools_build_py_module:
__author__ = "Sebastian Thiel"
__contact__ = "byronimo@gmail.com"
__homepage__ = "https://github.com/gitpython-developers/gitdb"
-version_info = (0, 5, 5)
+version_info = (0, 6, 0)
__version__ = '.'.join(str(i) for i in version_info)
setup(cmdclass={'build_ext':build_ext_nofail},
@@ -88,8 +88,8 @@ setup(cmdclass={'build_ext':build_ext_nofail},
ext_modules=[Extension('gitdb._perf', ['gitdb/_fun.c', 'gitdb/_delta_apply.c'], include_dirs=['gitdb'])],
license = "BSD License",
zip_safe=False,
- requires=('async (>=0.6.2)', 'smmap (>=0.8.3)'),
- install_requires=('async >= 0.6.1', 'smmap >= 0.8.0'),
+ requires=('smmap (>=0.8.3)'),
+ install_requires=('smmap >= 0.8.0'),
long_description = """GitDB is a pure-Python git object database""",
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[