Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7763507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:40:35+00:00 2026-06-01T14:40:35+00:00

I have a Python script that for-loops through some objects and fetches data from

  • 0

I have a Python script that for-loops through some objects and fetches data from a url in xml-format and stores it in a MySQL db. I have attached a (simplified) version of the script below. I schedule the script to run once per day with the Windows Task Scheduler. The script and the scheduling works fine most of the time but once or twice per month the script terminates unexpectedly somewhere halfway through without any logged exceptions. When I detect that the script has terminated and manually rerun the script it completes without any problems and without any changes. The Windows Scheduler never reports any issues when the script has terminated prematurely, i.e. the ‘History’-tab just reports Action completed/Task completed just like it does when everything works as planned.

Simplified version of script:

for Obj in objects:
   t=0
   dbdata = ''
   logger.info('Object: {s}\tID: {i}'.format(s=Obj.name, i=Obj.id))
    try:
        url = 'http://www.xyz.com/webproxy/DataProxy.aspx?Object=' + Obj.id
        logger.debug(url)
        data = urlopen(url)
        dom = minidom.parse(data)
        for node in reversed(dom.getElementsByTagName('t')):
            dbdata = dbdata + str(node.getAttribute('t')) + '\t' + str(float(node.getAttribute('p'))) + '\t' + str(int(node.getAttribute('v'))) + '\t' + str(node.getAttribute('id')) + '\t' + str(node.getAttribute('b')) + '\t' + str(node.getAttribute('s')) + '\n'
            t=t+1
        if len(dbdata)>0:
            cursor.execute(sql,(Obj.id,Obj.name,daydb,dbdata))
        logger.info('# rows: {n}'.format(n=t)
    except HTTPError, e:
        logger.error(e.msg)
        logger.error('HTTPError. Error code: ' + str(e.code))
    except ExpatError, ex:
        logger.error(ex.msg)
        logger.error('Expat Error. Error code: ' + str(ex.code))
    except Exception, e:
        logger.error(e.msg)
        logger.error('Exception. Error code: ' + str(e.code))

Does anyone have any ideas why the script terminates prematurely every once in a while or if there is anything that i can do in the script or in the scheduling to avoid this problem or at least add some clarity to what is happening? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:40:36+00:00Added an answer on June 1, 2026 at 2:40 pm

    you said: “without any logged exceptions”?

    This may be because Exception is not the base class of all exceptions

    >>> help(Exception)
    Help on class Exception in module exceptions:
    
    class Exception(BaseException)
     |  Common base class for all non-exit exceptions.
     |  
     |  Method resolution order:
     |      Exception
     |      BaseException
     |      __builtin__.object
    

    BaseException is the base class.

    However I recommend this if you want to get all exceptions:

    try:
       ...
    except:
        import sys
        error_type, error, traceback = sys.exc_info()
    

    This way you also catch SystemExit

    >>> SystemExit.mro()
    [<type 'exceptions.SystemExit'>, <type 'exceptions.BaseException'>, <type 'object'>]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python script that reads through a text csv file and creates
I have a python script that retrieves information from a web service and then
Basically I have a script in Python that grabs the text from an open
I have af python script that download attchments from a POP3 mailbox. But I
I have a python script that generates a bunch of data in a while
I have a Python script that uses built-in modules but also imports a number
I have a python script that uses threads and makes lots of HTTP requests.
I have a python script that uses plt.show() as it's last instruction. When it
I have a Python script that is running a few ls commands. This script
I have a python script that ends with running a program (iexpress.exe) in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.