Пример #1
0
 def test_setRunTimeout (self):
     c = NDN ()
     c.run(0)
     
     def change_timeout():
         # print("Changing timeout!")
         c.setRunTimeout(1000)
     
     t = Timer(0.1, change_timeout)
     t.start()
     
     org_start = datetime.now()
     while True:
             self.assertLess ((datetime.now() - org_start).seconds, 3) # setRunTimeout() failed
     
     	start = datetime.now()
     	c.run(5)
     	diff = datetime.now() - start
     
     	if diff.seconds * 1000000 + diff.microseconds > 500000:
     		break
Пример #2
0
    def test_setRunTimeout(self):
        c = NDN()
        c.run(0)

        def change_timeout():
            # print("Changing timeout!")
            c.setRunTimeout(1000)

        t = Timer(0.1, change_timeout)
        t.start()

        org_start = datetime.now()
        while True:
            self.assertLess((datetime.now() - org_start).seconds,
                            3)  # setRunTimeout() failed

            start = datetime.now()
            c.run(5)
            diff = datetime.now() - start

            if diff.seconds * 1000000 + diff.microseconds > 500000:
                break
Пример #3
0
from threading import Timer
from datetime import datetime

handle = _pyndn.create()

try:
    _pyndn.run(handle, 100)
except _pyndn.NDNError:
    pass
else:
    raise AssertionError("ndn_run() should fail when not connected")

del handle

c = NDN()
c.run(0)


def change_timeout():
    print("Changing timeout!")
    c.setRunTimeout(1000)


t = Timer(0.1, change_timeout)
t.start()

org_start = datetime.now()
while True:
    if (datetime.now() - org_start).seconds > 3:
        raise AssertionError("setRunTimeout() failed")
Пример #4
0
from pyndn import NDN, Name, Interest, Closure
from time import sleep

worked = False

class MyClosure(Closure):
	def upcall(self, kind, upcallInfo):
		global worked

		print("Got response")
		print(kind)
		print(upcallInfo)
		worked = True

n = Name("ndn:/ndnx/ping")

i = Interest()
closure = MyClosure()

c = NDN()
res = c.expressInterest(n, closure, i)
print(res)

#causes crashes
c.run(10)
print("Ha!")
assert(worked)