From 3f997fa804060c0efc8b8dd47827d32338d9e113 Mon Sep 17 00:00:00 2001 From: bobloy Date: Thu, 21 Jan 2021 10:44:25 -0500 Subject: [PATCH] Fix to pickle error and Nonetype comparison --- fifo/__init__.py | 10 ++++++++++ fifo/date_trigger.py | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fifo/__init__.py b/fifo/__init__.py index 34cfd7b..2d5e103 100644 --- a/fifo/__init__.py +++ b/fifo/__init__.py @@ -1,5 +1,15 @@ +import sys + from .fifo import FIFO +# Applying fix from: https://github.com/Azure/azure-functions-python-worker/issues/640 +# [Fix] Create a wrapper for importing imgres +from .date_trigger import * +from . import CustomDateTrigger + +# [Fix] Register imgres into system modules +sys.modules["CustomDateTrigger"] = CustomDateTrigger + async def setup(bot): cog = FIFO(bot) diff --git a/fifo/date_trigger.py b/fifo/date_trigger.py index eb3d617..b024750 100644 --- a/fifo/date_trigger.py +++ b/fifo/date_trigger.py @@ -4,4 +4,7 @@ from apscheduler.triggers.date import DateTrigger class CustomDateTrigger(DateTrigger): def get_next_fire_time(self, previous_fire_time, now): next_run = super().get_next_fire_time(previous_fire_time, now) - return next_run if next_run >= now else None + return next_run if next_run is not None and next_run >= now else None + + def __getstate__(self): + return {"version": 1, "run_date": self.run_date}