mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 10:01:54 +00:00
Merge pull request #837 from tahoe-lafs/3451.immutable-downloader-start-python-3
Start porting allmydata.immutable.downloader to Python 3 Fixes ticket:3451
This commit is contained in:
commit
1182ed0508
0
newsfragments/3451.minor
Normal file
0
newsfragments/3451.minor
Normal file
@ -1,4 +1,15 @@
|
||||
"""
|
||||
Ported to Python 3.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
|
||||
from twisted.python.failure import Failure
|
||||
from foolscap.api import eventually
|
||||
@ -222,7 +233,7 @@ class SegmentFetcher(object):
|
||||
# add_shares() or no_more_shares() later.
|
||||
|
||||
def _cancel_all_requests(self):
|
||||
for o in self._share_observers.values():
|
||||
for o in list(self._share_observers.values()):
|
||||
o.cancel()
|
||||
self._share_observers = {}
|
||||
|
||||
|
@ -1,3 +1,14 @@
|
||||
"""
|
||||
Ported to Python 3.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
|
||||
import time
|
||||
now = time.time
|
||||
|
@ -1,3 +1,14 @@
|
||||
"""
|
||||
Ported to Python 3.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
|
||||
import time
|
||||
now = time.time
|
||||
|
@ -1334,6 +1334,21 @@ class FakeNode(object):
|
||||
|
||||
|
||||
class Selection(unittest.TestCase):
|
||||
def test_failure(self):
|
||||
"""If the fetch loop fails, it tell the Node the fetch failed."""
|
||||
node = FakeNode()
|
||||
# Simulate a failure:
|
||||
node.get_num_segments = lambda: 1/0
|
||||
sf = SegmentFetcher(node, 0, 3, None)
|
||||
sf.add_shares([])
|
||||
d = flushEventualQueue()
|
||||
def _check1(ign):
|
||||
[_] = self.flushLoggedErrors(ZeroDivisionError)
|
||||
self.failUnless(node.failed)
|
||||
self.failUnless(node.failed.check(ZeroDivisionError))
|
||||
d.addCallback(_check1)
|
||||
return d
|
||||
|
||||
def test_no_shares(self):
|
||||
node = FakeNode()
|
||||
sf = SegmentFetcher(node, 0, 3, None)
|
||||
|
@ -32,6 +32,9 @@ PORTED_MODULES = [
|
||||
"allmydata.crypto.rsa",
|
||||
"allmydata.crypto.util",
|
||||
"allmydata.hashtree",
|
||||
"allmydata.immutable.downloader.fetcher",
|
||||
"allmydata.immutable.downloader.finder",
|
||||
"allmydata.immutable.downloader.segmentation",
|
||||
"allmydata.immutable.happiness_upload",
|
||||
"allmydata.immutable.literal",
|
||||
"allmydata.interfaces",
|
||||
|
Loading…
x
Reference in New Issue
Block a user