# -*- coding: utf-8 -*-

import ioport

class Connection(object):
    """ Connection class for IPFBlock
    
        Connection binding OPort and IPort of some IPFBlocks 
    """


    def __init__(self, oport, iport):
        # Check port compatibility and free of input port
        if ioport.is_connect_allowed(oport, iport):
            self._oport = oport
            self._iport = iport
            self._oport.increase_binded_count()
            self._iport.set_binded()
        else:
            raise ValueError("Can not create Connection with given ports")
            
    def __del__(self):
        self._oport.decrease_binded_count()
        self._iport.set_free()
        
        
    def contains_port(self, port):
        return self._iport == port or self._oport == port
        
        
    def process(self):
        """ Send value from output port to input port """
        self._iport.pass_value(self._oport.get_value())
        
        
@@ -31,16 +31,31 @@
 t ioport
+%0Aimport weakref
 %0A%0Aclass 
@@ -363,21 +363,34 @@
 oport = 
+weakref.ref(
 oport
+)
 %0A       
@@ -408,21 +408,34 @@
 iport = 
+weakref.ref(
 iport
+)
 %0A       
@@ -450,16 +450,18 @@
 f._oport
+()
 .increas
@@ -496,24 +496,26 @@
  self._iport
+()
 .set_binded(
@@ -660,16 +660,18 @@
 f._oport
+()
 .decreas
@@ -706,16 +706,18 @@
 f._iport
+()
 .set_fre
@@ -795,24 +795,26 @@
  self._iport
+()
  == port or 
@@ -824,16 +824,18 @@
 f._oport
+()
  == port
@@ -953,16 +953,18 @@
 f._iport
+()
 .pass_va
@@ -978,16 +978,18 @@
 f._oport
+()
 .get_val

Change _oport and _iport to weakref for prevention of loop references