| msg55062 - (view) |
Author: lomm (korka) |
Date: 2007-04-17 08:29 |
| These are a few examples of errors during code-reentry in the turtle module: System tested: Windows XP sp2, Python 2.5 1. turtle.circle fails if the tkinter is closed while drawing. # Code example: import turtle turtle.circle(100) # close the tkinter window while the circle is drawing # will give an "invalid command name" exception 2. using multiple inheritance, it's possible to draw more than 1 turtle running around at a time. This works part of the time, but crashes python completely on occasions. # Code example: import turtle, random from threading import Thread class Ninja(Thread, turtle.Turtle): 'A ninja is a threaded turtle' def __init__(self): # constructors Thread.__init__(self) turtle.Turtle.__init__(self) # where will i go? self.Direction = random.randint(-180,180) def run(self): # that way! self.left(self.Direction) # march 'forward' for i in range(50): self.forward(16*random.random()) self.left(22 - 45*random.random()) ninjas = [] for i in range(3): ninjas.append(Ninja()) ninjas[-1].start() |
|
|
| msg55063 - (view) |
Author: Josiah Carlson (josiahcarlson) *  |
Date: 2007-04-19 05:12 |
| Does Turtle claim to be thread safe in the documentation? Should we explicitly state that Turtle is not thread safe? Should we also say, "don't close the turtle window while it is drawing"? |
|
|
| msg55064 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2007-04-19 06:58 |
| As Josiah says, the current docs do not make any promises about thread-safety. So, this isn't a bug. That being said, it would be nice to offer a way to have multiple turtles running around under the control of different threads. |
|
|
| msg120464 - (view) |
Author: Alexander Belopolsky (belopolsky) *  |
Date: 2010-11-05 02:08 |
| I think threading is a red herring here. The issue is really a duplicate of #6639. |
|
|
| msg120465 - (view) |
Author: Alexander Belopolsky (belopolsky) *  |
Date: 2010-11-05 02:19 |
| On a closer look at the first post, I see that there are two parts to the issue. The first is indeed a duplicate of #6639, but the second is thread related. I am attaching the OP's code in a script file for convenience. Running ninja.py under python3 produces RuntimeError: main thread is not in main loop in every ninja thread. This looks like tkinter limitation, but I think it is possible to work around it in turtle, so this is a valid feature request. +1 |
|
|
| msg224436 - (view) |
Author: Lita Cho (Lita.Cho) * |
Date: 2014-07-31 18:25 |
| Hey! So I have been investigating this bug, but I wanted to know is the issue the fact that korka wants to create multiple turtles or do you really want to use multiple threads with Turtle? I feel like this crash is due to Tkinter not being thread safe and I am not sure how turtle can go about working around this other than creating a scheduler within turtle. |
|
|
| msg224437 - (view) |
Author: Lita Cho (Lita.Cho) * |
Date: 2014-07-31 18:32 |
| I also want to note that you can create duplicate turtles by using clone, and I am not sure why you would use multiple inheritance to draw more than 1 turtle running around. I didn't think turtle was meant to be used this way. In order to draw multiple turtles, I would use the clone method. Is this to draw turtles running at the same time? |
|
|
| msg319746 - (view) |
Author: Carol Willing (willingc) *  |
Date: 2018-06-16 15:08 |
| Hi all, I'm triaging 'turtle' open issues. I'm going to close this issue with a resolution of not a Turtle bug. Thanks. |
|
|