[Tutor] TimeOut in
OkaMthembo
zebra05 at gmail.com
Wed Nov 11 18:22:22 CET 2009
Hi Somnath,
I think the exception simply means that the thread object or class does not
have a cancel function. maybe read docs on Python threads to see what
functions can be called on those?
On Sun, Nov 8, 2009 at 9:09 PM, somnath chakrabarti <
chakrabarti.somnath at gmail.com> wrote:
> 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.
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
Regards,
Lloyd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091111/19871165/attachment-0001.htm>
More information about the Tutor
mailing list