nonnymoose / xsr

X Steps Recorder
MIT License
80 stars 17 forks source link

Fix the issue where finish() runs twice #57

Closed nonnymoose closed 7 years ago

nonnymoose commented 7 years ago

I did this by calling the exit function at the end of finish(). Should fix #56 .

nonnymoose commented 7 years ago

@lezsakdomi Do you think this is an acceptable solution to the problem? This way, if the behavior of perl changes again for some reason, it will still clean up properly.

nonnymoose commented 7 years ago

Whoops, looks like I merged it anyway by resolving the conflicts. @lezsakdomi Let me know if there's a problem.

nonnymoose commented 7 years ago

@lezsakdomi Yes, but either way, it will trigger the finish() at the end of the program and the SIGTERM finish(), so I felt like it would be a better idea to just exit at the end of finish() so it won't be executed twice.

This has the added benefit that it will still work if Perl's behavior changes back to what it was while I was originally developing psr.

lezsakdomi commented 7 years ago

@nonnymoose Ok. Then do it the python way:

  1. Leave the call at the end of file, as originally
  2. Before entering mainloop: Trap a function, which tracks wether SIGTERM got (or simply terminates mainloop, in this case skip step 3 :) )
  3. In mainloop: Check in every run wether we should quit (or do it more perlic)
  4. After mainloop: Cancel that trap (...) (and call finish)
nonnymoose commented 7 years ago

@lezsakdomi Okay, I will do that. It is not necessary, however, to remove the trap after mainloop because mainloop won't be checking that flag any more. Should I still do it for good practice?

lezsakdomi commented 7 years ago

@nonnymoose: One more function, which wastes CPU time :) So yes, do for good practice, please. Maybe in the future it would matter.