FYI: AI-programmer

Ian Kelly ian.g.kelly at gmail.com
Fri Feb 22 22:23:08 CET 2013


On Fri, Feb 22, 2013 at 6:04 AM, Andrew Robinson
<andrew3 at r3dsolutions.com> wrote:
> It's still surprising that even C# would allow a killing of threads.
>
> Resources can be allocated by a thread and tied up was one of the comments
> made on the site I linked; so those resources could be permanently tied up
> until process exit if the thread is killed.
>
> eg: killing a thread is different from killing the process it is running in.
>
> I'm not familiar enough with C# to know if it does garbage collection or
> not, or how de-allocation is handled; so perhaps I missed something.

I have no idea where C# stands on forced thread termination.  I only
pointed out that it was C# because you specifically referred to
Python.

> How would you get an interpreter thread to check for a shutdown request
> every N cycles?
> I've read about how to set a timeout based on time, but not on any kind of
> cycle (eg: instruction cycle?) count.

A "cycle" here would be the execution of one Brainfuck instruction.
The control loop would look something like this:

while True:
    if shutdown_event.is_set():
        break
    for i in range(N):
        interpreter.cycle()



More information about the Python-list mailing list