From a4ec35885831f80df1f178536041c2f6d60c2fa5 Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Thu, 3 Aug 2023 11:48:52 +0900 Subject: [PATCH 01/15] Resolve task unlimited repeat bug Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- discord/ext/tasks/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 400786d8a4..3a652164c8 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -575,7 +575,11 @@ def _get_next_sleep_time(self) -> datetime.datetime: if self._current_loop == 0: # if we're at the last index on the first iteration, we need to sleep until tomorrow return datetime.datetime.combine( - datetime.datetime.now(datetime.timezone.utc) + datetime.datetime.now( + self._time[0].tzinfo + if self._time[0].tzinfo is not None + else datetime.timezone.utc + ) + datetime.timedelta(days=1), self._time[0], ) @@ -586,11 +590,19 @@ def _get_next_sleep_time(self) -> datetime.datetime: self._time_index += 1 if next_time > datetime.datetime.now(datetime.timezone.utc).timetz(): return datetime.datetime.combine( - datetime.datetime.now(datetime.timezone.utc), next_time + datetime.datetime.now( + next_time.tzinfo + if next_time.tzinfo is not None + else datetime.timezone.utc + ), next_time ) else: return datetime.datetime.combine( - datetime.datetime.now(datetime.timezone.utc) + datetime.datetime.now( + next_time.tzinfo + if next_time.tzinfo is not None + else datetime.timezone.utc + ) + datetime.timedelta(days=1), next_time, ) From 797de23a7c265e9c500b6a0753ec746206faca64 Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Fri, 4 Aug 2023 01:54:57 +0900 Subject: [PATCH 02/15] Fix bug for first init Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- discord/ext/tasks/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 3a652164c8..348f4927f6 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -588,7 +588,11 @@ def _get_next_sleep_time(self) -> datetime.datetime: if self._current_loop == 0: self._time_index += 1 - if next_time > datetime.datetime.now(datetime.timezone.utc).timetz(): + if next_time > datetime.datetime.now( + next_time.tzinfo + if next_time.tzinfo is not None + else datetime.timezone.utc + ).timetz(): return datetime.datetime.combine( datetime.datetime.now( next_time.tzinfo From 8228dce2eb623d15cc867862bcda60b072187faa Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Fri, 4 Aug 2023 02:19:38 +0900 Subject: [PATCH 03/15] fix bug for 2nd or above Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- discord/ext/tasks/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 348f4927f6..42547a6969 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -611,7 +611,7 @@ def _get_next_sleep_time(self) -> datetime.datetime: next_time, ) - next_date = cast(datetime.datetime, self._last_iteration) + next_date = cast(datetime.datetime, self._last_iteration.astimezone(next_time.tzinfo)) if next_time < next_date.timetz(): next_date += datetime.timedelta(days=1) From 201709f6f7dc12a548eb6539b93ea496160e602a Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:09:05 +0900 Subject: [PATCH 04/15] add fix to CHANGELOG.md Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ceeaf33723..e73f3f8695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -162,6 +162,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#2191](https://github.com/Pycord-Development/pycord/pull/2191)) - Fixed a misplaced payload object inside of the thread creation payload. ([#2192](https://github.com/Pycord-Development/pycord/pull/2192)) +- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not UTC ## [2.4.1] - 2023-03-20 From cd28653e3349d246ebb0a55c9a4014e24ed8deda Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:20:12 +0900 Subject: [PATCH 05/15] =?UTF-8?q?change=20:=20Naive=ED=95=9C=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EB=88=84=EB=9D=BD=EB=90=9C=20=EA=B1=B0=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e73f3f8695..1340d43f06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -162,7 +162,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#2191](https://github.com/Pycord-Development/pycord/pull/2191)) - Fixed a misplaced payload object inside of the thread creation payload. ([#2192](https://github.com/Pycord-Development/pycord/pull/2192)) -- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not UTC +- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not `None` or UTC ## [2.4.1] - 2023-03-20 From de8f86596cd39d8028d6510ddd29fec75b004153 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 5 Aug 2023 06:26:27 +0000 Subject: [PATCH 06/15] style(pre-commit): auto fixes from pre-commit.com hooks --- CHANGELOG.md | 3 ++- discord/ext/tasks/__init__.py | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1340d43f06..05dd32b29a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -162,7 +162,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2191](https://github.com/Pycord-Development/pycord/pull/2191)) - Fixed a misplaced payload object inside of the thread creation payload. ([#2192](https://github.com/Pycord-Development/pycord/pull/2192)) -- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not `None` or UTC +- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not `None` or + UTC ## [2.4.1] - 2023-03-20 diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 42547a6969..cf63e1d132 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -588,17 +588,21 @@ def _get_next_sleep_time(self) -> datetime.datetime: if self._current_loop == 0: self._time_index += 1 - if next_time > datetime.datetime.now( - next_time.tzinfo - if next_time.tzinfo is not None - else datetime.timezone.utc - ).timetz(): + if ( + next_time + > datetime.datetime.now( + next_time.tzinfo + if next_time.tzinfo is not None + else datetime.timezone.utc + ).timetz() + ): return datetime.datetime.combine( datetime.datetime.now( next_time.tzinfo if next_time.tzinfo is not None else datetime.timezone.utc - ), next_time + ), + next_time, ) else: return datetime.datetime.combine( @@ -611,7 +615,9 @@ def _get_next_sleep_time(self) -> datetime.datetime: next_time, ) - next_date = cast(datetime.datetime, self._last_iteration.astimezone(next_time.tzinfo)) + next_date = cast( + datetime.datetime, self._last_iteration.astimezone(next_time.tzinfo) + ) if next_time < next_date.timetz(): next_date += datetime.timedelta(days=1) From 856e5861dd7f05d5ddebe286e36b192d6a2bed10 Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Tue, 15 Aug 2023 13:51:15 +0900 Subject: [PATCH 07/15] Update CHANGELOG.md Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05dd32b29a..54804f40fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -162,8 +162,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2191](https://github.com/Pycord-Development/pycord/pull/2191)) - Fixed a misplaced payload object inside of the thread creation payload. ([#2192](https://github.com/Pycord-Development/pycord/pull/2192)) -- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not `None` or - UTC +- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not `None` or UTC +([#2196](https://github.com/Pycord-Development/pycord/pull/2196)) ## [2.4.1] - 2023-03-20 From 7c358adb86d86bc5a4eef53d831a2db73f10487f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 04:51:33 +0000 Subject: [PATCH 08/15] style(pre-commit): auto fixes from pre-commit.com hooks --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54804f40fd..a5e8af4feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -162,8 +162,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2191](https://github.com/Pycord-Development/pycord/pull/2191)) - Fixed a misplaced payload object inside of the thread creation payload. ([#2192](https://github.com/Pycord-Development/pycord/pull/2192)) -- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not `None` or UTC -([#2196](https://github.com/Pycord-Development/pycord/pull/2196)) +- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not `None` or + UTC ([#2196](https://github.com/Pycord-Development/pycord/pull/2196)) ## [2.4.1] - 2023-03-20 From 3d311869f41f1c41e884484b21ece03369f0feee Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Wed, 16 Aug 2023 00:30:33 +0900 Subject: [PATCH 09/15] Update discord/ext/tasks/__init__.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- discord/ext/tasks/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index cf63e1d132..4c63f92658 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -575,11 +575,7 @@ def _get_next_sleep_time(self) -> datetime.datetime: if self._current_loop == 0: # if we're at the last index on the first iteration, we need to sleep until tomorrow return datetime.datetime.combine( - datetime.datetime.now( - self._time[0].tzinfo - if self._time[0].tzinfo is not None - else datetime.timezone.utc - ) + datetime.datetime.now(self._time[0].tzinfo or datetime.timezone.utc) + datetime.timedelta(days=1), self._time[0], ) From 5d829b5085d00bc67828a91694a9065c9c3879c7 Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Wed, 16 Aug 2023 00:30:41 +0900 Subject: [PATCH 10/15] Update discord/ext/tasks/__init__.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- discord/ext/tasks/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 4c63f92658..50606d3b36 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -586,11 +586,7 @@ def _get_next_sleep_time(self) -> datetime.datetime: self._time_index += 1 if ( next_time - > datetime.datetime.now( - next_time.tzinfo - if next_time.tzinfo is not None - else datetime.timezone.utc - ).timetz() + > datetime.datetime.now(next_time.tzinfo or datetime.timezone.utc).timetz() ): return datetime.datetime.combine( datetime.datetime.now( From fd3256420a5361cc5c4ddc7da6d38f9f8ba7bdee Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Wed, 16 Aug 2023 00:30:49 +0900 Subject: [PATCH 11/15] Update discord/ext/tasks/__init__.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- discord/ext/tasks/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 50606d3b36..c3a35d3b85 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -589,11 +589,7 @@ def _get_next_sleep_time(self) -> datetime.datetime: > datetime.datetime.now(next_time.tzinfo or datetime.timezone.utc).timetz() ): return datetime.datetime.combine( - datetime.datetime.now( - next_time.tzinfo - if next_time.tzinfo is not None - else datetime.timezone.utc - ), + datetime.datetime.now(next_time.tzinfo or datetime.timezone.utc), next_time, ) else: From 5d0a0485bc5cae807687041e8af27a399c324161 Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Wed, 16 Aug 2023 00:30:55 +0900 Subject: [PATCH 12/15] Update discord/ext/tasks/__init__.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> --- discord/ext/tasks/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index c3a35d3b85..e46335a82e 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -594,11 +594,7 @@ def _get_next_sleep_time(self) -> datetime.datetime: ) else: return datetime.datetime.combine( - datetime.datetime.now( - next_time.tzinfo - if next_time.tzinfo is not None - else datetime.timezone.utc - ) + datetime.datetime.now(next_time.tzinfo or datetime.timezone.utc) + datetime.timedelta(days=1), next_time, ) From 116217c3b88837e0e10f3f48edb0e46c9c5e6762 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:31:25 +0000 Subject: [PATCH 13/15] style(pre-commit): auto fixes from pre-commit.com hooks --- discord/ext/tasks/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index e46335a82e..81d39ab8d1 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -586,7 +586,9 @@ def _get_next_sleep_time(self) -> datetime.datetime: self._time_index += 1 if ( next_time - > datetime.datetime.now(next_time.tzinfo or datetime.timezone.utc).timetz() + > datetime.datetime.now( + next_time.tzinfo or datetime.timezone.utc + ).timetz() ): return datetime.datetime.combine( datetime.datetime.now(next_time.tzinfo or datetime.timezone.utc), From 58e017961544215b7094e29d8650d39f174d97a2 Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Sun, 26 Nov 2023 18:32:11 +0300 Subject: [PATCH 14/15] Update CHANGELOG.md Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52d72cec0d..6278f007c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -164,8 +164,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2191](https://github.com/Pycord-Development/pycord/pull/2191)) - Fixed a misplaced payload object inside of the thread creation payload. ([#2192](https://github.com/Pycord-Development/pycord/pull/2192)) -- Fixed infinity loop of `discord.ext.tasks.Loop` when task's `tzinfo` is not `None` or - UTC ([#2196](https://github.com/Pycord-Development/pycord/pull/2196)) +- Fixed tasks looping infinitely when `tzinfo` is neither `None` nor UTC. + ([#2196](https://github.com/Pycord-Development/pycord/pull/2196)) ## [2.4.1] - 2023-03-20 From bb75994e24e324f5505be919db820a5a2455822b Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Sun, 26 Nov 2023 18:35:33 +0300 Subject: [PATCH 15/15] oops Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef612847ea..3abc886053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -178,8 +178,6 @@ These changes are available on the `master` branch, but have not yet been releas ([#2191](https://github.com/Pycord-Development/pycord/pull/2191)) - Fixed a misplaced payload object inside of the thread creation payload. ([#2192](https://github.com/Pycord-Development/pycord/pull/2192)) -- Fixed tasks looping infinitely when `tzinfo` is neither `None` nor UTC. - ([#2196](https://github.com/Pycord-Development/pycord/pull/2196)) - Fixed `DMChannel.recipient` being `None` and consequently `User.dm_channel` also being `None`. ([#2219](https://github.com/Pycord-Development/pycord/pull/2219)) - Fixed ffmpeg being terminated prematurely when piping audio stream.