Created
August 17, 2015 18:04
-
-
Save agoose77/724c7f413d1f3e2a965b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
import os | |
current_directory = os.path.split(os.path.abspath(__file__))[0] | |
sys.path.append(current_directory + "/" + "..") | |
import hive | |
def build_h(i, ex, args): | |
print("Build hive", args.i) | |
if args.i: | |
ex.h = H(args.i-1) | |
def declare_h(args): | |
args.i = hive.parameter("int", 2) | |
H = hive.hive("H", build_h, declarator=declare_h) | |
h = H() | |
h2 = H() | |
assert h.h is not h2.h # h2 was a new instantation of a hiveobject (HiveBuilder.__new__) | |
assert h.h._hive_object is h2.h._hive_object # the getinstance call on h.h returned a new runhive, but has same HiveObject instance as h2.h | |
assert h.h.h is h2.h.h # because of the above assertion, when the runhive h2.h calls getinstance on its bees, it gets the same bees as h.h does | |
print(id(h.h.h), id(h2.h.h)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment