On Sat, Feb 8, 2020 at 4:41 AM Edward K. Ream <[email protected]> wrote:
> On Thu, Feb 6, 2020 at 1:08 PM Xu Wang <[email protected]> wrote: > >> Dear Leo Developer, >> >> I created one button in Leo, the corresponding script is: >> >> c.save() >> g.execute_shell_commands(['git -C /Users/wwww/leodata add austin.leo', >> 'git -C /Users/wwww/leodata commit -mupdates', '&git -C /Users/wwww/leodata >> push']) >> >> >> Basically, it will save the changes and do a git add/commit/push. >> > [...] > Do I need to do something extra in g.execute_shell_commands ? >> > > Good question. Sometimes Leo appears to hang (on Windows) after running > unit tests with g.execute_shell_commands. For me, a fix is to type a > <return> in the console from which Leo is running. > > I'm not sure what else can be done. The guts of g.execute_shell_commands > is just: > > proc = subprocess.Popen(command, shell=True) > if wait: proc.communicate() > > You could try experimenting with shell=False, but I doubt that will work. > Here is a thread from last year on the same topic: https://groups.google.com/d/msg/leo-editor/1VOYPUJrNEM/ItZwstC0AwAJ. In my emails there, I was assuming that running short-lived processes in the background will inevitably lead to zombies and I so I shared a workaround of doing the git commits with a long-running background process. But now I just noticed the subprocess oabjects have a poll method ( https://docs.python.org/3/library/subprocess.html#subprocess.Popen.poll). Maybe if g.execute_shell_commands is called with 'not wait', then leo should save the proc object and at idle time make a call to proc.poll for it (and any other launched background tasks). Then at the next idle call proc.poll again. Keep doing that until proc.poll doesn't return None. Brian -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAO5X8CyapLuNrzoQrtu9fsP-pXzdVuqBF4PmtPjypEBejZMwyQ%40mail.gmail.com.
