Skip to content

Commit

Permalink
Chech and set attr dynamically
Browse files Browse the repository at this point in the history
Instead of try catch
  • Loading branch information
cikay committed Nov 21, 2022
1 parent 2e1e81e commit 262e0c8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions redbeat/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ def ensure_conf(app):
"""
name = 'redbeat_conf'
app = app_or_default(app)
try:
config = getattr(app, name)
except AttributeError:
config = RedBeatConfig(app)
setattr(app, name, config)
if hasattr(app, name):
return getattr(app, name)

config = RedBeatConfig(app)
setattr(app, name, config)
return config


Expand Down

0 comments on commit 262e0c8

Please sign in to comment.