[Scons-users] Cleaning up a background process
Brian Cody
brian.j.cody at gmail.com
Tue Mar 21 14:09:22 EDT 2017
Bill,
While I was working towards a small example, I found my solution. It wasn't
actually an SCons issue at all. For those who might be wondering, the
functions registered with atexit() don't run when the main thread has
completed, as I had assumed. It runs when EVERY thread has completed. I was
intending to use atexit to clean up a thread, but it seems that the
requirement is the opposite. While looking into the multiprocessing module,
I discovered the fix which could be applied to threads as well. There is an
attribute called "daemon", which will automatically shutdown the thread if
only daemon threads/processes remain. After discovering this, I was able to
use a registered atexit hook to clean up the external process.
Thanks
On Tue, Mar 21, 2017 at 11:37 AM, Bill Deegan <bill at baddogconsulting.com>
wrote:
> Also, do you have a small example?
>
> On Tue, Mar 21, 2017 at 11:11 AM, Bill Deegan <bill at baddogconsulting.com>
> wrote:
>
>> It should work. It's been the proscribed method for some time, and other
>> users have discussed using it as recently as early march.
>>
>> Which version of SCons/Python and what platform?
>>
>> -Bill
>>
>> On Tue, Mar 21, 2017 at 10:29 AM, Brian Cody <brian.j.cody at gmail.com>
>> wrote:
>>
>>> Hey everyone,
>>>
>>> I have an issue that I pushed aside several months ago that I now need
>>> to revisit.
>>>
>>> A few build steps require a background process to be running. If
>>> anything goes wrong during the build, that background process needs to be
>>> killed. Also if nothing goes wrong during the build, the process must be
>>> killed on completion. It's launched with an action now. There seems to be
>>> no consistent way to be able to tell when all targets that would use the
>>> process are completed. Instead, I was thinking to register with atexit on
>>> spawning the process to hook in the cleanup function.
>>>
>>> I get that it isn't directly supported but I'm not sure why it isn't
>>> working. The atexit._exithandlers list looks good before sys.exit is called
>>> in Script/Main.py, but the handlers just aren't called.
>>>
>>> Is there a known fix for atexit when combined with SCons? Is there any
>>> other sort of hook that I may be missing? Or a completely new suggestion?
>>>
>>> Thank you
>>>
>>> -Brian
>>>
>>>
>>>
>>> _______________________________________________
>>> Scons-users mailing list
>>> Scons-users at scons.org
>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>
>>>
>>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170321/c13c907f/attachment.html>
More information about the Scons-users
mailing list