Skip to content

Commit 5ecf870

Browse files
committed
Remove support for non-async immediate tasks
1 parent b497300 commit 5ecf870

2 files changed

Lines changed: 7 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: 6 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
@@ -17,7 +16,7 @@
1716
from django_guid import get_guid
1817
from pulpcore.app.apps import MODULE_PLUGIN_VERSIONS
1918
from pulpcore.app.models import Task, TaskGroup
20-
from pulpcore.app.util import current_task, get_domain, get_prn, deprecation_logger
19+
from pulpcore.app.util import current_task, get_domain, get_prn
2120
from pulpcore.constants import (
2221
TASK_FINAL_STATES,
2322
TASK_INCOMPLETE_STATES,
@@ -81,19 +80,11 @@ def _execute_task(task):
8180
immediate = task.immediate
8281
is_coroutine_fn = asyncio.iscoroutinefunction(func)
8382

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

9686
if is_coroutine_fn:
87+
# both regular and immediate tasks can be coroutines, but only immediate must timeout
9788
_logger.debug("Task is coroutine %s", task.pk)
9889
coro = func(*args, **kwargs)
9990
if immediate:
@@ -110,6 +101,8 @@ def _execute_task(task):
110101
timeout=IMMEDIATE_TIMEOUT,
111102
)
112103
)
104+
else:
105+
func(*args, **kwargs)
113106

114107
except Exception:
115108
exc_type, exc, tb = sys.exc_info()

0 commit comments

Comments
 (0)