Skip to content

Commit 3c7b33e

Browse files
committed
Remove support for non-async immediate tasks
1 parent f5d03dd commit 3c7b33e

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed support for synchronous immediate tasks.

pulpcore/tasking/tasks.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import traceback
99
import tempfile
1010
import threading
11-
from asgiref.sync import sync_to_async
1211
from gettext import gettext as _
1312

1413
from django.conf import settings
@@ -21,7 +20,6 @@
2120
current_task,
2221
get_domain,
2322
get_prn,
24-
deprecation_logger,
2523
)
2624
from pulpcore.constants import (
2725
TASK_FINAL_STATES,
@@ -86,19 +84,11 @@ def _execute_task(task):
8684
immediate = task.immediate
8785
is_coroutine_fn = asyncio.iscoroutinefunction(func)
8886

89-
if not is_coroutine_fn:
90-
if immediate:
91-
deprecation_logger.warning(
92-
"Immediate tasks must be coroutine functions. "
93-
"Support for non-coroutine immediate tasks will be dropped "
94-
"in pulpcore 3.85."
95-
)
96-
func = sync_to_async(func)
97-
is_coroutine_fn = True
98-
else:
99-
func(*args, **kwargs)
87+
if immediate and not is_coroutine_fn:
88+
raise ValueError("Immediate tasks must be async functions.")
10089

10190
if is_coroutine_fn:
91+
# both regular and immediate tasks can be coroutines, but only immediate must timeout
10292
_logger.debug("Task is coroutine %s", task.pk)
10393
coro = func(*args, **kwargs)
10494
if immediate:
@@ -115,6 +105,8 @@ def _execute_task(task):
115105
timeout=IMMEDIATE_TIMEOUT,
116106
)
117107
)
108+
else:
109+
func(*args, **kwargs)
118110

119111
except Exception:
120112
exc_type, exc, tb = sys.exc_info()

0 commit comments

Comments
 (0)