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;
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:
- I have a python CLI script for getting some data from the net.
- 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.
- The subprocess manages network connections and caches, the main script only starts the subprocess and then asks all what it needs from the subprocess.
- The subsequent main script runs do not start a subprocess — they use the already running one.
- If subprocess don't get the any requests from main script for some time it should shut down itself.
- 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
add a comment |
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:
- I have a python CLI script for getting some data from the net.
- 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.
- The subprocess manages network connections and caches, the main script only starts the subprocess and then asks all what it needs from the subprocess.
- The subsequent main script runs do not start a subprocess — they use the already running one.
- If subprocess don't get the any requests from main script for some time it should shut down itself.
- 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
add a comment |
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:
- I have a python CLI script for getting some data from the net.
- 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.
- The subprocess manages network connections and caches, the main script only starts the subprocess and then asks all what it needs from the subprocess.
- The subsequent main script runs do not start a subprocess — they use the already running one.
- If subprocess don't get the any requests from main script for some time it should shut down itself.
- 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
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:
- I have a python CLI script for getting some data from the net.
- 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.
- The subprocess manages network connections and caches, the main script only starts the subprocess and then asks all what it needs from the subprocess.
- The subsequent main script runs do not start a subprocess — they use the already running one.
- If subprocess don't get the any requests from main script for some time it should shut down itself.
- 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
python process
asked Mar 24 at 15:06
shau-koteshau-kote
5171620
5171620
add a comment |
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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