question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PRAW can't seem to find praw.ini files created during program run-time

See original GitHub issue

Describe the bug I have an algorithm that catches the Reddit instance not finding a praw.ini file and creates one, then goes back and re-creates the Reddit instance, however, even after the file is created, it can’t find anything. If I close the program and re-run after the file is created, it works fine.

To Reproduce Steps to reproduce the behavior:

  1. Create a small write algorithm (or I can send mine) that creates a praw.ini file from user inputs
  2. Initiate Reddit without a praw.ini file
  3. Have the error caught and redirected to the file-creation algorithm
  4. Have it than attempt to initiate again once the new file is created

Expected behavior I expected it to return to the beginning of my while loop, recognise that there is now a sufficient praw.ini file, and continue with the porgram.

Code/Logs I’m including the Reddit() instance because 1. it doesn’t have any private credentials visible due pulling them from a .ini file, and 2. it’s the problem.

instance = False
attempts = 0
while instance == False:
    if attempts == 3:
        print("Could not find required praw.ini attributes after 3 attempts. Exiting.")
        sys.exit(0)
    try:
        reddit = praw.Reddit("cdrcredentials", user_agent=config["os"]+":claimdoneremover:v"+version+" (by u/MurdoMaclachlan)")
        instance = True
    except (configparser.NoSectionError, praw.exceptions.MissingRequiredAttributeException):
        createIni(home)
        attempts += 1

Logs-wise, it isn’t throwing any errors or giving log messages, it’s just going back into the except and calling createIni() again. I can send createIni() if need be, but it’s only a simple file-creation function, and itself is working exactly as intended.

System Info

  • OS: Linux (Slackware 14.2)
  • Python: 3.7
  • PRAW Version: 7.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bboecommented, Nov 1, 2020

Actually, based on my own testing it looks like PRAW reads the praw.ini file once per program execution, so it won’t detect changes after the first read. I didn’t realize that was the behavior.

I think it’d be acceptable to have a way to replace the global config with a new one, or to reload an existing one.

0reactions
github-actions[bot]commented, May 31, 2021

This issue was closed because it has been stale for 10 days with no activity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

praw.ini Files — PRAW 7.6.1 documentation - Read the Docs
PRAW comes with a praw. ini file in the package directory, and looks for user defined praw. ini files in a few other...
Read more >
NoSectionError - Praw can't find praw.ini : r/redditdev
I'm having some issues with praw not being able to locate my praw.ini file which is in the current working directory AND in...
Read more >
PRAW script task, can't find bot1 in praw.ini : Forums
PRAW script task, can't find bot1 in praw.ini ... Running on local machine and through bash console works, but not through the scheduled...
Read more >
Cannot find PRAW config file when wrapping application ...
The strange thing is I navigated to the first path, unzipped site-packages.zip and found praw.ini inside /praw, so I'm not really sure why...
Read more >
"You provided the name of a praw.ini configuration which ...
I cloned your project into Visual Studio, and when I run the code, after a few seconds this error appears. Do you have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found