Create a file that attaches to the lifetime of the process in python











up vote
0
down vote

favorite












I'm looking for away to create a file that is attached for the life time of the process, and that another process can access it.



Assume process A that creates a file, assume process B that can access this file (so it needs to know its location) , now when process A is being shutdown (no matter the cause) the file is being deleted.



As far as I can tell tmpfile is not good enough as process B would not be able to locate the file (in trivial way)



Any other ideas?



Thanks,










share|improve this question




























    up vote
    0
    down vote

    favorite












    I'm looking for away to create a file that is attached for the life time of the process, and that another process can access it.



    Assume process A that creates a file, assume process B that can access this file (so it needs to know its location) , now when process A is being shutdown (no matter the cause) the file is being deleted.



    As far as I can tell tmpfile is not good enough as process B would not be able to locate the file (in trivial way)



    Any other ideas?



    Thanks,










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm looking for away to create a file that is attached for the life time of the process, and that another process can access it.



      Assume process A that creates a file, assume process B that can access this file (so it needs to know its location) , now when process A is being shutdown (no matter the cause) the file is being deleted.



      As far as I can tell tmpfile is not good enough as process B would not be able to locate the file (in trivial way)



      Any other ideas?



      Thanks,










      share|improve this question















      I'm looking for away to create a file that is attached for the life time of the process, and that another process can access it.



      Assume process A that creates a file, assume process B that can access this file (so it needs to know its location) , now when process A is being shutdown (no matter the cause) the file is being deleted.



      As far as I can tell tmpfile is not good enough as process B would not be able to locate the file (in trivial way)



      Any other ideas?



      Thanks,







      python python-3.x






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 8 at 8:42

























      asked Nov 8 at 8:32









      Eden

      1,70411317




      1,70411317
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          To attach the file lifetime with the process lifetime you can use signal handling (Cf. doc). You just need to call



          signal(SIGTERM, your_deleting_file_method) 


          inside the A process. By doing this you are free to define a static filename if it meets your need.






          share|improve this answer








          New contributor




          T.Lucas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203985%2fcreate-a-file-that-attaches-to-the-lifetime-of-the-process-in-python%23new-answer', 'question_page');
            }
            );

            Post as a guest
































            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote



            accepted










            To attach the file lifetime with the process lifetime you can use signal handling (Cf. doc). You just need to call



            signal(SIGTERM, your_deleting_file_method) 


            inside the A process. By doing this you are free to define a static filename if it meets your need.






            share|improve this answer








            New contributor




            T.Lucas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






















              up vote
              2
              down vote



              accepted










              To attach the file lifetime with the process lifetime you can use signal handling (Cf. doc). You just need to call



              signal(SIGTERM, your_deleting_file_method) 


              inside the A process. By doing this you are free to define a static filename if it meets your need.






              share|improve this answer








              New contributor




              T.Lucas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.




















                up vote
                2
                down vote



                accepted







                up vote
                2
                down vote



                accepted






                To attach the file lifetime with the process lifetime you can use signal handling (Cf. doc). You just need to call



                signal(SIGTERM, your_deleting_file_method) 


                inside the A process. By doing this you are free to define a static filename if it meets your need.






                share|improve this answer








                New contributor




                T.Lucas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                To attach the file lifetime with the process lifetime you can use signal handling (Cf. doc). You just need to call



                signal(SIGTERM, your_deleting_file_method) 


                inside the A process. By doing this you are free to define a static filename if it meets your need.







                share|improve this answer








                New contributor




                T.Lucas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                T.Lucas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered Nov 8 at 9:05









                T.Lucas

                462




                462




                New contributor




                T.Lucas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                T.Lucas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                T.Lucas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203985%2fcreate-a-file-that-attaches-to-the-lifetime-of-the-process-in-python%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest




















































































                    Popular posts from this blog

                    Schultheiß

                    Verwaltungsgliederung Dänemarks

                    Liste der Kulturdenkmale in Wilsdruff