alcemirfernandes / pynguin

Automatically exported from code.google.com/p/pynguin
GNU General Public License v3.0
0 stars 0 forks source link

ctrl+c breaks loops, creates unexpected behavior #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run a While loop or some other procedure
2. Interrupt it by hitting Ctrl + C
3. Things break =(

What is the expected output? What do you see instead?
The loop/process stops.  Instead, the turtle gets confused.

What version of the product are you using? On what operating system?
0.7

Please provide any additional information below.

Original issue reported on code.google.com by aresnick...@gmail.com on 30 May 2010 at 3:54

GoogleCodeExporter commented 9 years ago
Thanks for the report. Getting this loop-break behavior correct has been the 
most
difficult part of this project...

For me, it is mostly working properly now, so:

Can you be more specific about what gets confused?
Does the loop actually stop?
Do you get the KeyboardInterrupt message?
Can you post the actual code you are running, the output, or a description of 
the
problem?
What operating system are you running?
What version of PyQt?

Finally: Could you try again with the development version (from mercurial)?

Original comment by miss...@hotmail.com on 30 May 2010 at 8:19

GoogleCodeExporter commented 9 years ago
> Can you be more specific about what gets confused?

There are a few ways it gets confused: the penguin loses its position or skips 
steps 
(so in drawing a circle, it will start drawing a straight line) or you can tell 
that 
it's missing commands because it kinda precesses if you're holding down ctrl+c 
while 
it is attempting to draw a circle, for example.  This all happens in the 
intervening 
second when you're hitting ^C a lot or holding it down in an attempt to get it 
to 
stop.

> Does the loop actually stop?

Eventually.

> Do you get the KeyboardInterrupt message?

Yep.

> Can you post the actual code you are running, the output, or a description of 
the
problem?

Sure--the code is just a while True: fd(1) rt(1) thing.  I'll post a screenshot 
later 
today.

> What operating system are you running?

Ubuntu 9.10

> What version of PyQt?

python-qt4_4.6-1_amd64

Original comment by aresnick...@gmail.com on 2 Jun 2010 at 7:46

GoogleCodeExporter commented 9 years ago
Also, I will try with the dev version; thanks!

Original comment by aresnick...@gmail.com on 2 Jun 2010 at 7:46

GoogleCodeExporter commented 9 years ago
I just don't see anything like this.
I'm running on both Ubuntu 9.10 and on 10.04 also.

When I press Ctrl-C it stops running almost instantly.
Even when running something like the multi.pyn follow
example with 20 pynguins, Ctrl-C stops it quick.

How long does it take to stop once you press Ctrl-C?
What speed is the machine you are using?
What speed are you using in pynguin (Slow, Medium,
Fast, Instant, or doesn't affect the problem)?

Let's hope the dev version fixes your problem. If
not, definitely post a screenshot. That may help
me see what is happening.

Thanks!

Original comment by miss...@hotmail.com on 2 Jun 2010 at 8:18

GoogleCodeExporter commented 9 years ago
Here's an example of the failure: http://drop.io/onhtk2d  -- it should draw a 
circle, 
but every time I press ^C, it forgets about turning, and goes straight, or 
doesn't 
turn enough.

Let me know if that needs more explanation.

> How long does it take to stop once you press Ctrl-C?

Depends--anywhere from on the first try, to like five seconds while holding it 
down 
or hitting it repeatedly.

> What speed is the machine you are using?

1.4GHz

> What speed are you using in pynguin (Slow, Medium,
Fast, Instant, or doesn't affect the problem)?

Medium; haven't tried others; will.

Original comment by aresnick...@gmail.com on 3 Jun 2010 at 3:00

GoogleCodeExporter commented 9 years ago
I've seen behavior like you are describing before, but I cannot reproduce it in 
the
development version. Hopefully I've fixed the problem already.

I will try to get a 0.8 release out this weekend. Or try the dev version 
directly.

Original comment by miss...@hotmail.com on 5 Jun 2010 at 12:52

GoogleCodeExporter commented 9 years ago
That is actually with the dev version, I believe.

Original comment by aresnick...@gmail.com on 5 Jun 2010 at 3:18

GoogleCodeExporter commented 9 years ago
> That is actually with the dev version

Oh. That's not what I wanted to hear :o/

Ok. I added some code that should prevent the application of any movements after
ctrl-c has been pressed.

Please hg pull and hg update and try it again.

Also, make sure you have a clean checkout -- no files left over from previous 
versions.

Thanks!

Original comment by miss...@hotmail.com on 5 Jun 2010 at 6:47

GoogleCodeExporter commented 9 years ago
Great!  Now it stops immediately, but the penguin still gets bumped off its 
path (so 
you can't stop him and start him back up in the route he was going.)

Thanks so much for your help; this is fantastic.

Original comment by aresnick...@gmail.com on 6 Jun 2010 at 3:27

GoogleCodeExporter commented 9 years ago
And here's a screenshot of that phenomenon: 

Original comment by aresnick...@gmail.com on 6 Jun 2010 at 4:01

Attachments:

GoogleCodeExporter commented 9 years ago
Furthermore, when you hit ^C and then clear, for some reason the pen goes 
up--i.e. ^C 
+ clear() + fd(100) does not draw a line of length 100 from where ^C 
intercepted the 
penguin.

Original comment by aresnick...@gmail.com on 6 Jun 2010 at 1:34

GoogleCodeExporter commented 9 years ago
> the penguin still gets bumped off its path

But you are not re-starting from where he left off, you are starting over from 
the
beginning.

So... if you Ctrl-C at the end of the rt(30) then when you start again you will 
get
another rt(30) so he won't go over the exact same path again.

If you need him to always follow the exact same path, you need to start from a 
known
location and orientation each time:

def homecircle():
    home()
    while True:
        rt(30)
        fd(30)

The problem is you don't have much control over when the ctrl-c event will fire 
and
interrupt the running code.

I could possibly see a desire for a more reliable signal to use. Maybe a 
different
key combo (ctrl-x for example) could set a variable that you could check for at 
a
particular point in your code:

def watchcircle():
    while not self.Stop:
        rt(30)
        lt(30)

But that is really a separate issue.

If that functionality is important to you, please file a separate issue. Thanks!

Original comment by miss...@hotmail.com on 6 Jun 2010 at 3:49

GoogleCodeExporter commented 9 years ago
re: Comment 11

This is a separate bug. It happens without using ctrl-c at all. Good catch.

fd(100)
clear()
fd(100)

Looks like pen is up.

Original comment by miss...@hotmail.com on 6 Jun 2010 at 3:57