Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log.exception does not work when there is no exception #11

Open
evandrocoan opened this issue Feb 25, 2019 · 0 comments
Open

log.exception does not work when there is no exception #11

evandrocoan opened this issue Feb 25, 2019 · 0 comments

Comments

@evandrocoan
Copy link
Owner

It outputs:

Traceback (most recent call last):
  File "./python3.3/logging/__init__.py", line 939, in emit
  File "./python3.3/logging/__init__.py", line 810, in format
  File "./python3.3/logging/__init__.py", line 556, in format
  File "./python3.3/logging/__init__.py", line 506, in formatException
  File "./python3.3/traceback.py", line 156, in print_exception
  File "./python3.3/traceback.py", line 122, in _iter_chain
AttributeError: 'NoneType' object has no attribute '__context__'
Logged from file third_part.py, line 176

For the input:

def load_data_file(file_path, wait_on_error=True, log_level=1, exceptions=False):
    channel_dictionary = OrderedDict()

    if os.path.exists( file_path ):
        maximum_attempts = 10

        while maximum_attempts > 0:

            try:
                with open( file_path, 'r', encoding='utf-8' ) as data_file:
                    return json.load( data_file, object_pairs_hook=OrderedDict )

            except ValueError as error:
                log( 1, "maximum_attempts %d, %s (%s)" % ( maximum_attempts, error, file_path ) )
                maximum_attempts -= 1

                if wait_on_error:
                    time.sleep( 0.1 )

        if maximum_attempts < 1:
            log.exception( "Could not open the file_path: %s" % ( file_path ) )
            if exceptions: raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant