LottaMe / pylet

A tool to learn python that is inspired by rustlings.
MIT License
0 stars 0 forks source link

Fix bug, sometimes program doesnt react to file changes #44

Closed LottaMe closed 5 months ago

LottaMe commented 5 months ago

Current Problem: Reacts to first on_modified If result is successful, you can remove the I am done comment If result again fails, modifying doesn’t work If you save again without removing I am done comment it doesn’t re-execute, but you can still remove I am done comment to continue

LottaMe commented 5 months ago

Problem:

Not looking for file modification after it has already been modified. It does go to the next exercise if file is checked for # I AM NOT DONE comment.

Investigation why:

In runner these lines

try:
    filechangehandler.process.start()
        filechangehandler.process.join()


Finish when the process is terminated by on_modified. It doesn’t matter if result is successful or not, it treats the exercise as completed. The reason it is not continuing, is because of these lines in exercise.run method:

while self.check_wait():
    time.sleep(1)
        continue

Now, it is continuously checking check_wait. We have two possibilities here:

  1. The file still had errors, so result.success == False. Without a new execution of the code (which is not happening right now) this will mean check_wait always returns true and pylet is stuck.
  2. The file does not have errors, so result.success == True. Changes to the file won’t do anything, as the observer is already off, but check_wait will return true if check_done_comment is false. Now check_done_comment is currently not reading exercise.code, but the file at exercise.path, so it actually reads the newer version of the file and returns False if we have removed the # I AM DONE comment.

Where to go from here:

Brainstorming without wifi:

Just copying the while loop from exercise does not really work, because: <bound method Exercise.check_wait of <exercise.Exercise object at 0x103438160>>

Maybe we can return check_wait from the process and restart it if check_wait is True?

Loop iteration is ending before the on modified is joined…

When is the process finished???

Idea:

Keep opening new processes, then close and join all of them in the end (--> how many can this support??