How to make a persistent subprocess for a CLI script?How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?How to get the current time in PythonHow can I make a time delay in Python?How do I sort a dictionary by value?How to make a chain of function decorators?How to make a flat list out of list of listsHow do I list all files of a directory?

Is the decompression of compressed and encrypted data without decryption also theoretically impossible?

Cause of continuous spectral lines

What risks are there when you clear your cookies instead of logging off?

Traffic law UK, pedestrians

Managing libraries hosted on EmacsWiki

What LISP compilers and interpreters were available for 8-bit machines?

Can characters escape from Death House through this method?

Java guess the number

What is the advantage of carrying a tripod and ND-filters when you could use image stacking instead?

Remove sudoers using script

Avoiding cliches when writing gods

siunitx error: Invalid numerical input

Why only the fundamental frequency component is said to give useful power?

Building a road to escape Earth's gravity by making a pyramid on Antartica

Incremental Ranges!

Will TSA allow me to carry a Continuous Positive Airway Pressure (CPAP)/sleep apnea device?

Does the "6 seconds per round" rule apply to speaking/roleplaying during combat situations?

How to make thick Asian sauces?

What happens if flight issues delay my arrival to the UK by less then 24 hours with a Tier 2 Visa?

Etymology of 'calcit(r)are'?

How to translate “Me doing X” like in online posts?

Where does this pattern of naming products come from?

What happens when the attacking player dies to damage triggers after killing the blocking creatures in the first combat step of double strike?

How can drunken, homicidal elves successfully conduct a wild hunt?



How to make a persistent subprocess for a CLI script?


How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?How to get the current time in PythonHow can I make a time delay in Python?How do I sort a dictionary by value?How to make a chain of function decorators?How to make a flat list out of list of listsHow do I list all files of a directory?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I've encountered with a task described below and have no idea how to solve it.



(I know it's generally a no-no to ask a question without any code or own attempts but I have no clue even to googling. My answer is not about "give me a solution", it's about "advice me what to look at" and "how to get it right".)



Okay, the task:



  1. I have a python CLI script for getting some data from the net.

  2. When the script runs the first time it should start a subprocess, which will be running (in idle) even when the main script will be end.

  3. The subprocess manages network connections and caches, the main script only starts the subprocess and then asks all what it needs from the subprocess.

  4. The subsequent main script runs do not start a subprocess — they use the already running one.

  5. If subprocess don't get the any requests from main script for some time it should shut down itself.

  6. The subsequent main script runs will have to start a subprocess again.

I know I can use the subprocess module in the main script to start a background process and communicate with it.
But how to check whether subprocess is already running and connect to it?
How to detect that a subprocess is unused for a long time to shut down it?



Usually I prefer a relatively low-level means — more my own code, but simpler building blocks.

If my task is fairly hard to solve this way and there is a powerful high-level library for that — I would be glad to know about it too.



Thank you.










share|improve this question




























    0















    I've encountered with a task described below and have no idea how to solve it.



    (I know it's generally a no-no to ask a question without any code or own attempts but I have no clue even to googling. My answer is not about "give me a solution", it's about "advice me what to look at" and "how to get it right".)



    Okay, the task:



    1. I have a python CLI script for getting some data from the net.

    2. When the script runs the first time it should start a subprocess, which will be running (in idle) even when the main script will be end.

    3. The subprocess manages network connections and caches, the main script only starts the subprocess and then asks all what it needs from the subprocess.

    4. The subsequent main script runs do not start a subprocess — they use the already running one.

    5. If subprocess don't get the any requests from main script for some time it should shut down itself.

    6. The subsequent main script runs will have to start a subprocess again.

    I know I can use the subprocess module in the main script to start a background process and communicate with it.
    But how to check whether subprocess is already running and connect to it?
    How to detect that a subprocess is unused for a long time to shut down it?



    Usually I prefer a relatively low-level means — more my own code, but simpler building blocks.

    If my task is fairly hard to solve this way and there is a powerful high-level library for that — I would be glad to know about it too.



    Thank you.










    share|improve this question
























      0












      0








      0








      I've encountered with a task described below and have no idea how to solve it.



      (I know it's generally a no-no to ask a question without any code or own attempts but I have no clue even to googling. My answer is not about "give me a solution", it's about "advice me what to look at" and "how to get it right".)



      Okay, the task:



      1. I have a python CLI script for getting some data from the net.

      2. When the script runs the first time it should start a subprocess, which will be running (in idle) even when the main script will be end.

      3. The subprocess manages network connections and caches, the main script only starts the subprocess and then asks all what it needs from the subprocess.

      4. The subsequent main script runs do not start a subprocess — they use the already running one.

      5. If subprocess don't get the any requests from main script for some time it should shut down itself.

      6. The subsequent main script runs will have to start a subprocess again.

      I know I can use the subprocess module in the main script to start a background process and communicate with it.
      But how to check whether subprocess is already running and connect to it?
      How to detect that a subprocess is unused for a long time to shut down it?



      Usually I prefer a relatively low-level means — more my own code, but simpler building blocks.

      If my task is fairly hard to solve this way and there is a powerful high-level library for that — I would be glad to know about it too.



      Thank you.










      share|improve this question














      I've encountered with a task described below and have no idea how to solve it.



      (I know it's generally a no-no to ask a question without any code or own attempts but I have no clue even to googling. My answer is not about "give me a solution", it's about "advice me what to look at" and "how to get it right".)



      Okay, the task:



      1. I have a python CLI script for getting some data from the net.

      2. When the script runs the first time it should start a subprocess, which will be running (in idle) even when the main script will be end.

      3. The subprocess manages network connections and caches, the main script only starts the subprocess and then asks all what it needs from the subprocess.

      4. The subsequent main script runs do not start a subprocess — they use the already running one.

      5. If subprocess don't get the any requests from main script for some time it should shut down itself.

      6. The subsequent main script runs will have to start a subprocess again.

      I know I can use the subprocess module in the main script to start a background process and communicate with it.
      But how to check whether subprocess is already running and connect to it?
      How to detect that a subprocess is unused for a long time to shut down it?



      Usually I prefer a relatively low-level means — more my own code, but simpler building blocks.

      If my task is fairly hard to solve this way and there is a powerful high-level library for that — I would be glad to know about it too.



      Thank you.







      python process






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 15:06









      shau-koteshau-kote

      5171620




      5171620






















          0






          active

          oldest

          votes












          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',
          autoActivateHeartbeat: false,
          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%2f55325185%2fhow-to-make-a-persistent-subprocess-for-a-cli-script%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325185%2fhow-to-make-a-persistent-subprocess-for-a-cli-script%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해