If you precede git command with the '&' g.execute_shell_commands will not 
wait for command to finish. IOW it will run in the background as you wish. 
You may wish to use subprocess module on your own and starting process with 
subprocess.Popen is fast enough, it won't block your main thread for more 
than a few milliseconds. Git command will run in its own separate process 
and exit after finishing.  Notice that there is no files watching involved, 
there is no need for long running processes either. 

Vitalije

On Sunday, September 15, 2019 at 3:53:33 PM UTC+2, btheado wrote:
>
> Thanks, Vitalije. I had rejected the 'save2' approach because I wanted to 
> run the git commit in the background so it wouldn't add any extra time to 
> the save. Using 'save2' doesn't preclude running the process in the 
> background, but if I take the "naive" approach of using 
> g.execute_shell_commands, then I'm left with the issue of defunct 
> processes (since that function never calls the communicate method for 
> background processes). So I was left with the choice between learning more 
> about Popen and just using the entr utility which I was already familiar 
> with. I chose the latter but that led to the issue of needing to use flock. 
> I may reconsider my choice.
>
> If I do reconsider, then your response will give me a head start on 
> properly using the 'save' hook.
>
>
> On Sun, Sep 15, 2019 at 9:07 AM vitalije <vita...@gmail.com <javascript:>> 
> wrote:
>
>> The essential part of the above script is just g.registerHandler('save2', 
>> my_callback). The rest is just for making possible to deactivate handler 
>> and to make every commit with the next natural number. While developing 
>> your handler, it is useful to be able to deactivate it in case of an error. 
>> Also if you change script and run it again it will register another version 
>> of your handler. Quite often, in development, I use the same method to 
>> un-register old version and then register the new one.
>>
>> def reactivate(tag, handler):
>>     k = '_activation_%s_handler'%tag
>>         # this is just to prevent collisions
>>         # you can use whatever string as a key
>>     old_handler = c.user_dict.pop(k, None)
>>     if old_handler:
>>         g.unregisterHandler(tag, old_handler)
>>     g.registerHandler(tag, handler)
>>     c.user_dict[k] = handler
>> reactivate('save2', my_callback)
>>
>> HTH Vitalije.
>>
>> -- 
>> 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 leo-e...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/leo-editor/630dd216-994f-4a7a-805a-e1b20ed2ae34%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/leo-editor/630dd216-994f-4a7a-805a-e1b20ed2ae34%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/83ff2275-6b85-4812-9748-04b890daf7e0%40googlegroups.com.

Reply via email to