python script stop execution not dead after hours





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







0















I am running an infinite python script in loops and catching all Exception so that script will not stop an execution.



the self.pupdate() function is fetching data from sql server and show it on a terminal, if by some reason it may be possible that it will not get data or something but it won't be stop. here is my code.



class live(Thread):
def __init__(self):
Thread.__init__(self)

def run(self):

while True:
try:
self.collect()
except Exception as Conerr:
print("run :",Conerr)
pass
def collect(self):
try:
while True:
self.rep()
pass
except Exception as mai:
print("Collect:", mai)
def rep(self):
try:
self.pick_update()
except Exception as F:
print("REP:",F)

if __name__ == '__main__':
fun = live()
fun.start()


the script is not going to dead it stop executing and stuck somewhere



edit 1:



to overcome this i tried threading.Timer as following code ,



def runs():
threading.Timer(30.0, runs).start()
try:
for i in range(1,10):
pick_update()
except Exception as yt:
print("datafetch: ", yt)


but an issue with this is that if the whole cycle not complete it will start new thread and previous one is also running, is that first thread stop when it's cycle is complete? or both the thread will continue and start new every time?










share|improve this question

























  • So what's the question?

    – arudzinska
    Nov 29 '18 at 8:58













  • the script stop by some reason, I want to find that and solve it so that the execution will not going to stop anyhow.

    – Nilanj
    Nov 29 '18 at 9:24











  • Is the pick_update using an external library that can crash by itself killing the process? highly likely if it is a DLL implementation then the crash wont propagate upto the python exception handler. Also, is the thread a daemon thread in which case you might need a fun.join().

    – Luv
    Nov 29 '18 at 9:51











  • no the thread is not deamon thread, the external libraries i am using is the only pymysql which is collecting data from sql server, i checked pymysql is not crashing, i tried debugging and printing the errors it is not giving any error and just stop. no errors

    – Nilanj
    Nov 30 '18 at 5:52


















0















I am running an infinite python script in loops and catching all Exception so that script will not stop an execution.



the self.pupdate() function is fetching data from sql server and show it on a terminal, if by some reason it may be possible that it will not get data or something but it won't be stop. here is my code.



class live(Thread):
def __init__(self):
Thread.__init__(self)

def run(self):

while True:
try:
self.collect()
except Exception as Conerr:
print("run :",Conerr)
pass
def collect(self):
try:
while True:
self.rep()
pass
except Exception as mai:
print("Collect:", mai)
def rep(self):
try:
self.pick_update()
except Exception as F:
print("REP:",F)

if __name__ == '__main__':
fun = live()
fun.start()


the script is not going to dead it stop executing and stuck somewhere



edit 1:



to overcome this i tried threading.Timer as following code ,



def runs():
threading.Timer(30.0, runs).start()
try:
for i in range(1,10):
pick_update()
except Exception as yt:
print("datafetch: ", yt)


but an issue with this is that if the whole cycle not complete it will start new thread and previous one is also running, is that first thread stop when it's cycle is complete? or both the thread will continue and start new every time?










share|improve this question

























  • So what's the question?

    – arudzinska
    Nov 29 '18 at 8:58













  • the script stop by some reason, I want to find that and solve it so that the execution will not going to stop anyhow.

    – Nilanj
    Nov 29 '18 at 9:24











  • Is the pick_update using an external library that can crash by itself killing the process? highly likely if it is a DLL implementation then the crash wont propagate upto the python exception handler. Also, is the thread a daemon thread in which case you might need a fun.join().

    – Luv
    Nov 29 '18 at 9:51











  • no the thread is not deamon thread, the external libraries i am using is the only pymysql which is collecting data from sql server, i checked pymysql is not crashing, i tried debugging and printing the errors it is not giving any error and just stop. no errors

    – Nilanj
    Nov 30 '18 at 5:52














0












0








0








I am running an infinite python script in loops and catching all Exception so that script will not stop an execution.



the self.pupdate() function is fetching data from sql server and show it on a terminal, if by some reason it may be possible that it will not get data or something but it won't be stop. here is my code.



class live(Thread):
def __init__(self):
Thread.__init__(self)

def run(self):

while True:
try:
self.collect()
except Exception as Conerr:
print("run :",Conerr)
pass
def collect(self):
try:
while True:
self.rep()
pass
except Exception as mai:
print("Collect:", mai)
def rep(self):
try:
self.pick_update()
except Exception as F:
print("REP:",F)

if __name__ == '__main__':
fun = live()
fun.start()


the script is not going to dead it stop executing and stuck somewhere



edit 1:



to overcome this i tried threading.Timer as following code ,



def runs():
threading.Timer(30.0, runs).start()
try:
for i in range(1,10):
pick_update()
except Exception as yt:
print("datafetch: ", yt)


but an issue with this is that if the whole cycle not complete it will start new thread and previous one is also running, is that first thread stop when it's cycle is complete? or both the thread will continue and start new every time?










share|improve this question
















I am running an infinite python script in loops and catching all Exception so that script will not stop an execution.



the self.pupdate() function is fetching data from sql server and show it on a terminal, if by some reason it may be possible that it will not get data or something but it won't be stop. here is my code.



class live(Thread):
def __init__(self):
Thread.__init__(self)

def run(self):

while True:
try:
self.collect()
except Exception as Conerr:
print("run :",Conerr)
pass
def collect(self):
try:
while True:
self.rep()
pass
except Exception as mai:
print("Collect:", mai)
def rep(self):
try:
self.pick_update()
except Exception as F:
print("REP:",F)

if __name__ == '__main__':
fun = live()
fun.start()


the script is not going to dead it stop executing and stuck somewhere



edit 1:



to overcome this i tried threading.Timer as following code ,



def runs():
threading.Timer(30.0, runs).start()
try:
for i in range(1,10):
pick_update()
except Exception as yt:
print("datafetch: ", yt)


but an issue with this is that if the whole cycle not complete it will start new thread and previous one is also running, is that first thread stop when it's cycle is complete? or both the thread will continue and start new every time?







python python-3.x python-multithreading






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 30 '18 at 6:33







Nilanj

















asked Nov 29 '18 at 5:30









NilanjNilanj

4010




4010













  • So what's the question?

    – arudzinska
    Nov 29 '18 at 8:58













  • the script stop by some reason, I want to find that and solve it so that the execution will not going to stop anyhow.

    – Nilanj
    Nov 29 '18 at 9:24











  • Is the pick_update using an external library that can crash by itself killing the process? highly likely if it is a DLL implementation then the crash wont propagate upto the python exception handler. Also, is the thread a daemon thread in which case you might need a fun.join().

    – Luv
    Nov 29 '18 at 9:51











  • no the thread is not deamon thread, the external libraries i am using is the only pymysql which is collecting data from sql server, i checked pymysql is not crashing, i tried debugging and printing the errors it is not giving any error and just stop. no errors

    – Nilanj
    Nov 30 '18 at 5:52



















  • So what's the question?

    – arudzinska
    Nov 29 '18 at 8:58













  • the script stop by some reason, I want to find that and solve it so that the execution will not going to stop anyhow.

    – Nilanj
    Nov 29 '18 at 9:24











  • Is the pick_update using an external library that can crash by itself killing the process? highly likely if it is a DLL implementation then the crash wont propagate upto the python exception handler. Also, is the thread a daemon thread in which case you might need a fun.join().

    – Luv
    Nov 29 '18 at 9:51











  • no the thread is not deamon thread, the external libraries i am using is the only pymysql which is collecting data from sql server, i checked pymysql is not crashing, i tried debugging and printing the errors it is not giving any error and just stop. no errors

    – Nilanj
    Nov 30 '18 at 5:52

















So what's the question?

– arudzinska
Nov 29 '18 at 8:58







So what's the question?

– arudzinska
Nov 29 '18 at 8:58















the script stop by some reason, I want to find that and solve it so that the execution will not going to stop anyhow.

– Nilanj
Nov 29 '18 at 9:24





the script stop by some reason, I want to find that and solve it so that the execution will not going to stop anyhow.

– Nilanj
Nov 29 '18 at 9:24













Is the pick_update using an external library that can crash by itself killing the process? highly likely if it is a DLL implementation then the crash wont propagate upto the python exception handler. Also, is the thread a daemon thread in which case you might need a fun.join().

– Luv
Nov 29 '18 at 9:51





Is the pick_update using an external library that can crash by itself killing the process? highly likely if it is a DLL implementation then the crash wont propagate upto the python exception handler. Also, is the thread a daemon thread in which case you might need a fun.join().

– Luv
Nov 29 '18 at 9:51













no the thread is not deamon thread, the external libraries i am using is the only pymysql which is collecting data from sql server, i checked pymysql is not crashing, i tried debugging and printing the errors it is not giving any error and just stop. no errors

– Nilanj
Nov 30 '18 at 5:52





no the thread is not deamon thread, the external libraries i am using is the only pymysql which is collecting data from sql server, i checked pymysql is not crashing, i tried debugging and printing the errors it is not giving any error and just stop. no errors

– Nilanj
Nov 30 '18 at 5:52












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%2f53532435%2fpython-script-stop-execution-not-dead-after-hours%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%2f53532435%2fpython-script-stop-execution-not-dead-after-hours%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

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)