Index: park_integration/AbstractFitEngine.py
===================================================================
--- park_integration/AbstractFitEngine.py	(revision 12b76cf6a382eb37b2de4a80da2561f9a17db539)
+++ park_integration/AbstractFitEngine.py	(revision fd6b7899a0c95c8d50c6e7d53b6028f1be87632f)
@@ -365,9 +365,9 @@
         self.model.setParams(self.paramlist,params)
         self.res= self.data.residuals(self.model.eval)
-        #if self.curr_thread != None :
-        #    try:
-        #        self.curr_thread.isquit()
-        #    except:
-        #        raise FitAbort,"stop leastsqr optimizer"    
+        if self.curr_thread != None :
+            try:
+                self.curr_thread.isquit()
+            except:
+                raise FitAbort,"stop leastsqr optimizer"    
         return self.res
     
@@ -435,33 +435,58 @@
         
         
-    def set_model(self,model,Uid,pars=[]):
+    def set_model(self,model,Uid,pars=[], constraints=[]):
         """
             set a model on a given uid in the fit engine.
-            @param model: the model to fit
+            @param model: sans.models type 
             @param Uid :is the key of the fitArrange dictionnary where model is saved as a value
             @param pars: the list of parameters to fit 
+            @param constraints: list of 
+                tuple (name of parameter, value of parameters)
+                the value of parameter must be a string to constraint 2 different
+                parameters.
+                Example:
+                we want to fit 2 model M1 and M2 both have parameters A and B.
+                constraints can be:
+                 constraints = [(M1.A, M2.B+2), (M1.B= M2.A *5),...,]
             @note : pars must contains only name of existing model's paramaters
         """
+        if model == None:
+            raise ValueError, "AbstractFitEngine: Need to set model to fit"
+        
+        new_model= model
+        if not issubclass(model.__class__, Model):
+            new_model= Model(model)
+        
+        if len(constraints)>0:
+            for constraint in constraints:
+                name, value = constraint
+                try:
+                    new_model.parameterset[ str(name)].set( str(value) )
+                except:
+                    msg= "Fit Engine: Error occurs when setting the constraint"
+                    msg += " %s for parameter %s "%(value, name)
+                    raise ValueError, msg
+                
         if len(pars) >0:
-            if model==None:
-                raise ValueError, "AbstractFitEngine: Specify parameters to fit"
-            else:
-                temp=[]
-                for item in pars:
-                    if item in model.model.getParamList():
-                        temp.append(item)
-                        self.paramList.append(item)
-                    else:
-                        raise ValueError,"wrong paramter %s used to set model %s. Choose\
-                            parameter name within %s"%(item, model.model.name,str(model.model.getParamList()))
-                        return
+            temp=[]
+            for item in pars:
+                if item in new_model.model.getParamList():
+                    temp.append(item)
+                    self.paramList.append(item)
+                else:
+                    
+                    msg = "wrong parameter %s used"%str(item)
+                    msg += "to set model %s. Choose"%str(new_model.model.name)
+                    msg += "parameter name within %s"%str(new_model.model.getParamList())
+                    raise ValueError,msg
+              
             #A fitArrange is already created but contains dList only at Uid
             if self.fitArrangeDict.has_key(Uid):
-                self.fitArrangeDict[Uid].set_model(model)
+                self.fitArrangeDict[Uid].set_model(new_model)
                 self.fitArrangeDict[Uid].pars= pars
             else:
             #no fitArrange object has been create with this Uid
                 fitproblem = FitArrange()
-                fitproblem.set_model(model)
+                fitproblem.set_model(new_model)
                 fitproblem.pars= pars
                 self.fitArrangeDict[Uid] = fitproblem
Index: park_integration/Fitting.py
===================================================================
--- park_integration/Fitting.py	(revision d8a2e319c1a65398e695444281e385d86c49c9d4)
+++ park_integration/Fitting.py	(revision fd6b7899a0c95c8d50c6e7d53b6028f1be87632f)
@@ -49,17 +49,17 @@
    
     
-    def fit(self,handler=None, curr_thread=None):
+    def fit(self,q=None,handler=None, curr_thread=None):
         """Perform the fit """
         try:
-            return self._engine.fit(handler, curr_thread= curr_thread)
+            return self._engine.fit(q,handler, curr_thread= curr_thread)
         except:
             raise
     
     
-    def set_model(self,model,Uid,pars=[]):
+    def set_model(self,model,Uid,pars=[],constraints=[]):
         """
         store a model model to fit at the position Uid of the fit engine
         """
-        self._engine.set_model(model,Uid,pars)
+        self._engine.set_model(model,Uid,pars,constraints)
    
    
Index: park_integration/ParkFitting.py
===================================================================
--- park_integration/ParkFitting.py	(revision d9dc51824451f32a2ca71d5916753a4c79d9b418)
+++ park_integration/ParkFitting.py	(revision fd6b7899a0c95c8d50c6e7d53b6028f1be87632f)
@@ -88,5 +88,5 @@
         
     
-    def fit(self,handler=None, curr_thread= None):
+    def fit(self,q=None,handler=None, curr_thread= None):
         """
             Performs fit with park.fit module.It can  perform fit with one model
@@ -120,4 +120,7 @@
         self.problem.all_results(result)
         if result !=None:
+            if q !=None:
+                q.put(result)
+                return q
             return result
         else:
Index: park_integration/ScipyFitting.py
===================================================================
--- park_integration/ScipyFitting.py	(revision d9dc51824451f32a2ca71d5916753a4c79d9b418)
+++ park_integration/ScipyFitting.py	(revision fd6b7899a0c95c8d50c6e7d53b6028f1be87632f)
@@ -61,5 +61,5 @@
     #    return profile(self._fit, *args, **kw)
 
-    def fit(self ,handler=None,curr_thread= None):
+    def fit(self ,q=None,handler=None,curr_thread= None):
        
         fitproblem=[]
@@ -81,30 +81,35 @@
         data=listdata
         self.curr_thread= curr_thread
+
+        #try:
+        functor= SansAssembly(self.paramList,model,data, curr_thread= self.curr_thread)
+        out, cov_x, info, mesg, success = optimize.leastsq(functor,model.getParams(self.paramList), full_output=1, warning=True)
         
-        try:
-            functor= SansAssembly(self.paramList,model,data, curr_thread= self.curr_thread)
-            out, cov_x, info, mesg, success = optimize.leastsq(functor,model.getParams(self.paramList), full_output=1, warning=True)
-            
-            chisqr = functor.chisq(out)
-            
-            if cov_x is not None and numpy.isfinite(cov_x).all():
-                stderr = numpy.sqrt(numpy.diag(cov_x))
-            else:
-                stderr=None
-            if not (numpy.isnan(out).any()) or ( cov_x !=None) :
-                    result = fitresult()
-                    result.fitness = chisqr
-                    result.stderr  = stderr
-                    result.pvec = out
-                    result.success = success
-                    return result
-            else:  
-                raise ValueError, "SVD did not converge"+str(success)
-        except FitAbort:
+        chisqr = functor.chisq(out)
+        
+        if cov_x is not None and numpy.isfinite(cov_x).all():
+            stderr = numpy.sqrt(numpy.diag(cov_x))
+        else:
+            stderr=None
+        if not (numpy.isnan(out).any()) or ( cov_x !=None) :
+                result = fitresult()
+                result.fitness = chisqr
+                result.stderr  = stderr
+                result.pvec = out
+                result.success = success
+                if q !=None:
+                    print "went here"
+                    q.put(result)
+                    print "get q scipy fit enfine",q.get()
+                    return q
+                return result
+        else:  
+            raise ValueError, "SVD did not converge"+str(success)
+        #except FitAbort:
             ## fit engine is stop
-            return None
+        #    return None
         
-        except:
-            raise
+        #except:
+        #    raise
        
 
Index: park_integration/test/small_test.py
===================================================================
--- park_integration/test/small_test.py	(revision 1e3169ca5ded9b29a2f1446318867ca1feadabc7)
+++ park_integration/test/small_test.py	(revision fd6b7899a0c95c8d50c6e7d53b6028f1be87632f)
@@ -3,5 +3,4 @@
 """
 import unittest
-from sans.fit.AbstractFitEngine import Model
 import math
 from sans.fit.Fitting import Fit
@@ -18,12 +17,11 @@
         # Receives the type of model for the fitting
         from sans.models.CylinderModel import CylinderModel
-        model1  = CylinderModel()
-        model1.setParam('contrast', 1)
-        model = Model(model1)
-        
+        model  = CylinderModel()
+        model.setParam('contrast', 1)
+       
         pars1 =['length','radius','scale']
         fitter.set_data(out,1)
-        model.set( scale=1e-10 )
-        fitter.set_model(model,1,pars1)
+        model.setParam('scale', 1e-10)
+        fitter.set_model(model,1,pars1, constraints=())
         fitter.select_problem_for_fit(Uid=1,value=1)
         result1 = fitter.fit()
Index: park_integration/test/test_fit_cylinder.py
===================================================================
--- park_integration/test/test_fit_cylinder.py	(revision 1e3169ca5ded9b29a2f1446318867ca1feadabc7)
+++ park_integration/test/test_fit_cylinder.py	(revision fd6b7899a0c95c8d50c6e7d53b6028f1be87632f)
@@ -17,13 +17,11 @@
         # Create model that fitting engine understands
         from sans.models.CylinderModel import CylinderModel
-        model1  = CylinderModel()
-        model1.setParam("scale", 1.0)
-        model1.setParam("radius",18)
-        model1.setParam("length", 397)
-        model1.setParam("contrast",3e-006 )
-        model1.setParam("background", 0.0)
-     
-        self.model = Model(model1)
-       
+        self.model  = CylinderModel()
+        self.model.setParam("scale", 1.0)
+        self.model.setParam("radius",18)
+        self.model.setParam("length", 397)
+        self.model.setParam("contrast",3e-006 )
+        self.model.setParam("background", 0.0)
+        #select parameters to fit
         self.pars1 =['length','radius','scale']
         
@@ -32,5 +30,4 @@
         fitter = Fit(name)
         fitter.set_data(self.data,1)
-        
         fitter.set_model(self.model,1,self.pars1)
         fitter.select_problem_for_fit(Uid=1,value=1)
Index: park_integration/test/test_fit_line.py
===================================================================
--- park_integration/test/test_fit_line.py	(revision 1e3169ca5ded9b29a2f1446318867ca1feadabc7)
+++ park_integration/test/test_fit_line.py	(revision fd6b7899a0c95c8d50c6e7d53b6028f1be87632f)
@@ -29,6 +29,7 @@
         try:fitter.set_model(model,1,pars1)
         except ValueError,msg:
-           assert str(msg)=="wrong paramter %s used to set model %s. Choose\
-                            parameter name within %s"%('param1', model.model.name,str(model.model.getParamList()))
+            print "ValueError was raised: "+str(msg)
+            #assert str(msg)=="wrong paramter %s used to set model %s. Choose\
+            #                 parameter name within %s"%('param1', model.model.name,str(model.model.getParamList()))
         else: raise AssertError,"No error raised for scipy fitting with wrong parameters name to fit"
         pars1= ['A','B']
