PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, November 14, 2022

[FIXED] How to handle non-generic errors in python?

 November 14, 2022     error-handling, python     No comments   

Issue

I have a loop that I run via the statement: os.system('python3 wrapper.py') which generates some files.

And every so often it hits an error such as this:

pybullet.error: Cannot load URDF file.
Error: InMemoryFile::~InMemoryFileIO (numAllocs 1 numFrees 2

This message is printed to the terminal. I would like to know how I can automatically get my code to start running again so long as the number of files generated is less than 20.

I tried the following:

while numberOfFilesGeneratedByLoop != 20:
     os.system('python3 wrapper.py')

However, it was still stopped by the same error.


Solution

python3 file.py > outputLog.txt

Log the output of your file to a .txt file, and then you can read through it. You can conditionally re-run your wrapper if the non-generic error statements are in outputLog.txt.



Answered By - FrustratedSnake
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,207,335

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing