Skip to content

Commit

Permalink
Merge pull request #1984 from avrae/nightly
Browse files Browse the repository at this point in the history
Merging Nightly to Master
  • Loading branch information
SeanStoves committed Jan 23, 2024
2 parents ff388c9 + 927f045 commit 5a3ac4e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cogs5e/models/homebrew/bestiary.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def _monster_factory_bestiary_builder(data, bestiary_name):
la_per_round=data["la_per_round"],
attacks=attacks,
proper=data["proper"],
image_url="",
image_url=data["image_url"],
spellcasting=spellcasting,
homebrew=True,
source=bestiary_name,
Expand Down
8 changes: 4 additions & 4 deletions cogs5e/sheets/dicecloudv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async def load_character(self, ctx, args):
race = None
subrace = None
background = None
for prop in self._by_type.get("folder") + self._by_type.get("feature") + self._by_type.get("note"):
for prop in self._by_type["folder"] + self._by_type["feature"] + self._by_type["note"]:
if race is None and "race" in prop["tags"]:
race = prop.get("name")
elif subrace is None and "subrace" in prop["tags"]:
Expand Down Expand Up @@ -200,7 +200,7 @@ async def get_character(self):

# keep track of which properties' parents weren't registered by the time we reach them
orphans = collections.defaultdict(lambda: []) # :'(
for prop in self.character_data.get("creatureProperties"):
for prop in self.character_data.get("creatureProperties", []):
# if a property is marked for removal, skip it
if prop.get("removed"):
continue
Expand Down Expand Up @@ -255,7 +255,7 @@ def _parse_attributes(self) -> (int, int, {str: int}, BaseStats, [Skill], [dict]
consumables = []

# we iterate over all attributes here so we don't have to loop over it multiple times
for attr in self._by_type.get("attribute"):
for attr in self._by_type["attribute"]:
if attr.get("inactive") or attr.get("overridden"):
continue
try:
Expand Down Expand Up @@ -365,7 +365,7 @@ def get_levels(self) -> Levels:

# setup a default dict for collecting class levels
levels = collections.defaultdict(lambda: 0)
for level in self._by_type.get("class"):
for level in self._by_type["class"]:
try:
var_name = level["variableName"]
# BloodHunter rather than bloodHunter
Expand Down
12 changes: 11 additions & 1 deletion dbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import time
import traceback
import gc


from redis import asyncio as redis
Expand Down Expand Up @@ -118,6 +119,9 @@ def __init__(self, prefix, description=None, **options):
self.glclient = GameLogClient(self)
self.glclient.init()

# lock for garbage collection
self.gc_lock = asyncio.Lock()

async def setup_rdb(self):
return RedisIO(await redis.from_url(url=config.REDIS_URL))

Expand Down Expand Up @@ -274,7 +278,13 @@ async def on_ready():

@bot.event
async def on_resumed():
log.info("resumed.")
if bot.gc_lock.locked():
return

async with bot.gc_lock:
await asyncio.sleep(2.0) # Wait for 2 seconds
collected = gc.collect() # Perform garbage collection
log.info(f"Garbage collector: collected {collected} objects.")


@bot.listen("on_command_error")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ d20==1.1.2
aiobotocore==2.1.0
redis==4.6.0
cachetools==4.2.2
disnake~=2.7.0
disnake~=2.9.1
gspread==3.7.0
httplib2==0.19.0
launchdarkly-server-sdk==7.2.0
Expand Down

0 comments on commit 5a3ac4e

Please sign in to comment.