[Tutor] TimeOut in

somnath chakrabarti chakrabarti.somnath at gmail.com
Sun Nov 8 20:09:11 CET 2009


Hi Alan,

I am importing the constraint library package in the beginning that is
having classes Problem, Solver and all the methods that I am calling. Now,
as you said after making the change from

        self.p = threading.Timer(100, self.onTimeout)

I am getting the below error. I am also attaching the constraint.py
package that my code is using

- Somnath


%%%%%%% Error Message %%%%%%%%%%%%%%%%%%%%

<constraint.BacktrackingSolver object at 0x02846F10>
Magic Square:
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python26\lib\threading.py", line 525, in __bootstrap_inner
    self.run()
  File "C:\Python26\lib\threading.py", line 477, in run
    self.__target(*self.__args, **self.__kwargs)
  File "C:\Users\Somnath\Documents\NetBeansProjects\CSC671\src\ms_t.py",
line 43, in getSolution
    self.solution=Problem.getSolution(self)
  File
"C:\Users\Somnath\Documents\NetBeansProjects\CSC671\src\constraint.py", line
215, in getSolution
    return self._solver.getSolution(domains, constraints, vconstraints)
  File
"C:\Users\Somnath\Documents\NetBeansProjects\CSC671\src\constraint.py", line
524, in getSolution
    return iter.next()
  File
"C:\Users\Somnath\Documents\NetBeansProjects\CSC671\src\constraint.py", line
506, in getSolutionIter
    pushdomains):
  File
"C:\Users\Somnath\Documents\NetBeansProjects\CSC671\src\constraint.py", line
1173, in __call__
    domain.hideValue(value)
  File
"C:\Users\Somnath\Documents\NetBeansProjects\CSC671\src\constraint.py", line
787, in hideValue
    list.remove(self, value)
ValueError: list.remove(x): x not in list
None
Time taken: 0.047

Traceback (most recent call last):
  File "C:\Users\Somnath\Documents\NetBeansProjects\CSC671\src\csc671.py",
line 125, in <module>
    ms_t.magic_square(size,func_solver())
  File "C:\Users\Somnath\Documents\NetBeansProjects\CSC671\src\ms_t.py",
line 68, in magic_square
    t.cancel()
AttributeError: 'Thread' object has no attribute 'cancel'
None
Time Exceeded Limit.


On Sun, Nov 8, 2009 at 12:17 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:

>
> "somnath chakrabarti" <chakrabarti.somnath at gmail.com> wrote
>
>
> Below is the code that I have written to do the timeout implementation. But
>> I am getting error as follows. Can anybody please help me where I am going
>> wrong?
>>
>
> I have no idea how this framework is upposed to work but my
> guess is that the problem lies here:
>
>
>   def getSolution(self,solver):
>>       Problem.setSolver(self,solver)
>>       self.p = threading.Timer(100, self.onTimeout())
>>
>
> Thios looks like you should be providing a callback
> function self.onTimeout but you are calling the function
> instead of referencing it. This calls the method before
> self.p has been defined.
>
> You need to remove the parentheses after Timeout.
>
> I think...
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Thanks and regards,
Somnath Chakrabarti.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091108/8e433d23/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: constraint.py
Type: application/octet-stream
Size: 50556 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20091108/8e433d23/attachment-0001.obj>


More information about the Tutor mailing list